Skip to content

Commit 0e2954d

Browse files
committed
readme: browser import example
1 parent befbac4 commit 0e2954d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ npm install imagescript # Node.js, Bun and bundlers
2323
deno add jsr:@matmen/imagescript # Deno
2424
```
2525

26+
Without a bundler, import it from jsDelivr in the browser:
27+
28+
```html
29+
<script type="module">
30+
import { Image } from 'https://cdn.jsdelivr.net/npm/imagescript@3/+esm';
31+
32+
const image = await Image.decode(await fetch('photo.jpg').then(r => r.arrayBuffer()));
33+
image.resize(256, Image.RESIZE_AUTO);
34+
const url = URL.createObjectURL(new Blob([await image.encode()], { type: 'image/png' }));
35+
document.body.append(Object.assign(document.createElement('img'), { src: url }));
36+
</script>
37+
```
38+
2639
---
2740

2841
### Example

0 commit comments

Comments
 (0)