imagescript 4.0.0-rc.6 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,17 +5,24 @@
5
5
  </picture>
6
6
  </h1>
7
7
 
8
- [![Documentation](https://img.shields.io/badge/Documentation-informational?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgcm9sZT0iaW1nIiBhcmlhLWxhYmVsPSJJbWFnZVNjcmlwdCI+PHRpdGxlPkltYWdlU2NyaXB0PC90aXRsZT48cGF0aCBkPSJNMTMyIDk2aC0xNGEzNCAzNCAwIDAgMC0zNCAzNHY3NGEzMCAzMCAwIDAgMS0zMCAzMGgtNnY0NGg2YTMwIDMwIDAgMCAxIDMwIDMwdjc0YTM0IDM0IDAgMCAwIDM0IDM0aDE0IE0zODAgOTZoMTRhMzQgMzQgMCAwIDEgMzQgMzR2NzRhMzAgMzAgMCAwIDAgMzAgMzBoNnY0NGgtNmEzMCAzMCAwIDAgMC0zMCAzMHY3NGEzNCAzNCAwIDAgMS0zNCAzNGgtMTQiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIzMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHJlY3QgeD0iMTY0IiB5PSIxNjQiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjI4IiB5PSIxNjQiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjkyIiB5PSIxNjQiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMTY0IiB5PSIyMjgiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjI4IiB5PSIyMjgiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjkyIiB5PSIyMjgiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMTY0IiB5PSIyOTIiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjI4IiB5PSIyOTIiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjkyIiB5PSIyOTIiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PC9zdmc+Cg==)](https://imagescript.dev/)
9
- [![Playground](https://img.shields.io/badge/Playground-Try%20it%20live-ff2d75?style=for-the-badge&labelColor=ff7a18&logoColor=white&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCc%2BPHBhdGggZmlsbD0nd2hpdGUnIGQ9J003IDQuNXYxNWwxMi41LTcuNXonLz48L3N2Zz4%3D)](https://try.imagescript.dev/)
10
-
11
- [![Github](https://img.shields.io/badge/Github-Repository-181717?logo=github&style=for-the-badge)](https://github.com/imagescript/ImageScript)
12
- [![Discord Server](https://img.shields.io/discord/691713541262147687.svg?label=Discord&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2&style=for-the-badge)](https://discord.gg/8hPrwAH)
8
+ <p align="center">
9
+ <a href="https://imagescript.dev/"><img alt="Documentation" src="https://img.shields.io/badge/Documentation-141821?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgcm9sZT0iaW1nIiBhcmlhLWxhYmVsPSJJbWFnZVNjcmlwdCI+PHRpdGxlPkltYWdlU2NyaXB0PC90aXRsZT48cGF0aCBkPSJNMTMyIDk2aC0xNGEzNCAzNCAwIDAgMC0zNCAzNHY3NGEzMCAzMCAwIDAgMS0zMCAzMGgtNnY0NGg2YTMwIDMwIDAgMCAxIDMwIDMwdjc0YTM0IDM0IDAgMCAwIDM0IDM0aDE0IE0zODAgOTZoMTRhMzQgMzQgMCAwIDEgMzQgMzR2NzRhMzAgMzAgMCAwIDAgMzAgMzBoNnY0NGgtNmEzMCAzMCAwIDAgMC0zMCAzMHY3NGEzNCAzNCAwIDAgMS0zNCAzNGgtMTQiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIzMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHJlY3QgeD0iMTY0IiB5PSIxNjQiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjI4IiB5PSIxNjQiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjkyIiB5PSIxNjQiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMTY0IiB5PSIyMjgiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjI4IiB5PSIyMjgiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjkyIiB5PSIyMjgiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMTY0IiB5PSIyOTIiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjI4IiB5PSIyOTIiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PHJlY3QgeD0iMjkyIiB5PSIyOTIiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgcng9IjEwIiBmaWxsPSIjZmZmIi8+PC9zdmc+Cg=="></a>
10
+ <a href="https://try.imagescript.dev/"><img alt="Playground" src="https://img.shields.io/badge/Playground-141821?style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCc%2BPHBhdGggZmlsbD0nd2hpdGUnIGQ9J003IDQuNXYxNWwxMi41LTcuNXonLz48L3N2Zz4%3D"></a>
11
+ <a href="https://github.com/imagescript/ImageScript/discussions"><img alt="Discussions" src="https://img.shields.io/badge/Discussions-141821?style=for-the-badge&logo=github&logoColor=white"></a>
12
+ <a href="https://discord.gg/8hPrwAH"><img alt="Discord" src="https://img.shields.io/badge/Discord-141821?style=for-the-badge&logo=discord&logoColor=white"></a>
13
+ </p>
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/imagescript"><img alt="npm" src="https://img.shields.io/npm/v/imagescript?style=flat-square&color=e85d8c&label=npm"></a>
16
+ <a href="https://jsr.io/@matmen/imagescript"><img alt="JSR" src="https://img.shields.io/jsr/v/@matmen/imagescript?style=flat-square&color=4c7df0&label=jsr"></a>
17
+ <a href="https://github.com/imagescript/ImageScript/actions/workflows/node.yml"><img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/imagescript/ImageScript/node.yml?branch=master&style=flat-square&label=tests"></a>
18
+ <a href="https://github.com/imagescript/ImageScript/blob/master/LICENSE"><img alt="MIT license" src="https://img.shields.io/npm/l/imagescript?style=flat-square&color=8e6cef&label=license"></a>
19
+ </p>
13
20
 
14
21
  ---
15
22
 
16
23
  **ImageScript** decodes, edits and encodes images in pure TypeScript: no WebAssembly, no native binaries, and no
17
- runtime dependencies. It runs in Node.js 22.13+, Deno, Bun, browsers and edge runtimes (Cloudflare Workers, Vercel's
18
- Edge Runtime, Deno Deploy), works with `import` and, on supported Node.js versions, `require()`, and ships with type
24
+ runtime dependencies. It runs in Node.js 22.13+, Deno, Bun, browsers and edge runtimes (such as Cloudflare
25
+ Workers), works with `import` and, on supported Node.js versions, `require()`, and ships with type
19
26
  definitions (TypeScript 5.7 or newer; CommonJS projects need `module: nodenext` and 5.8 or newer to `import` it (`module: node16` can't). With older versions and `skipLibCheck`, the encoders' return types become `any`). Large AVIF and JPEG XL operations, and lossless WebP encoding, can use multiple CPU cores when the runtime
20
27
  supports it.
21
28
 
@@ -26,28 +33,6 @@ deno add jsr:@matmen/imagescript # Deno
26
33
 
27
34
  Upgrading from 3.x? Read [Migrating to 4.0](https://github.com/imagescript/ImageScript/blob/master/guides/Migrating%20to%204.0.md) first.
28
35
 
29
- Without a bundler, import it from jsDelivr in the browser:
30
-
31
- ```html
32
- <script type="module">
33
- import { Image } from 'https://cdn.jsdelivr.net/npm/imagescript@4/+esm';
34
-
35
- const image = await Image.decode(await fetch('photo.jpg').then(r => r.arrayBuffer()));
36
- image.resize({ width: 256 });
37
- const url = URL.createObjectURL(new Blob([await image.encodePNG()], { type: 'image/png' }));
38
- document.body.append(Object.assign(document.createElement('img'), { src: url }));
39
- </script>
40
- ```
41
-
42
- The codecs that can use worker threads (large AVIF and JPEG XL images, lossless WebP; the `threads` option) do so in
43
- Node.js, Deno and Bun, and in browsers on cross-origin isolated pages. Where workers can't start, the work runs on the
44
- calling thread: the output is the same, only slower, and nothing warns about it. Browsers refuse workers from another
45
- origin, so the jsDelivr example above runs single-threaded; serve the package from your own origin (on a cross-origin
46
- isolated page) to get threads.
47
-
48
- Bundlers that write one file (esbuild, Rollup, `bun build`) don't copy the worker's module: serve `dist/util/worker.js` next to the
49
- bundle, or the same single-threaded fallback is used. webpack and Vite emit it.
50
-
51
36
  ---
52
37
 
53
38
  ### Example
@@ -61,14 +46,27 @@ image.resize({ width: 256 }).roundCorners({ radius: 16 });
61
46
  await writeFile('output.png', await image.encodePNG());
62
47
  ```
63
48
 
64
- <p align="center">
65
- <a href="https://try.imagescript.dev/">
66
- <img src="https://github.com/imagescript/ImageScript/raw/master/media/playground-cta.svg" alt="Try ImageScript in the Playground" width="440">
67
- </a>
68
- </p>
69
-
70
49
  [![Example](https://github.com/imagescript/ImageScript/raw/master/tests/targets/readme.png)](https://github.com/imagescript/ImageScript/blob/master/tests/readme.js)
71
50
 
51
+ The same code runs everywhere, only reading and writing the bytes differs. `Image.decode()` takes any `ArrayBuffer` or
52
+ typed array (`fetch(url).then(r => r.arrayBuffer())` in a browser or on an edge runtime, `Deno.readFile()`,
53
+ `Bun.file().arrayBuffer()`), and the encoders return a `Uint8Array`. In a browser without a bundler, import it from jsDelivr:
54
+
55
+ ```js
56
+ import { Image } from 'https://cdn.jsdelivr.net/npm/imagescript@4/+esm';
57
+ ```
58
+
59
+ ### Threads and bundlers
60
+
61
+ The codecs that can use worker threads (large AVIF and JPEG XL images, lossless WebP; the `threads` option) do so in
62
+ Node.js, Deno and Bun, and in browsers on cross-origin isolated pages. Where workers can't start, the work runs on the
63
+ calling thread: the output is the same, only slower, and nothing warns about it. Browsers refuse workers from another
64
+ origin, so the jsDelivr import above runs single-threaded; serve the package from your own origin (on a cross-origin
65
+ isolated page) to get threads.
66
+
67
+ Bundlers that write one file (esbuild, Rollup, `bun build`) don't copy the worker's module: serve `dist/util/worker.js` next to the
68
+ bundle, or the same single-threaded fallback is used. webpack and Vite emit it.
69
+
72
70
  ---
73
71
 
74
72
  ### Features
@@ -130,7 +128,3 @@ ImageScript builds on [fflate](https://github.com/101arrowz/fflate), libjpeg, [p
130
128
  [libjxl](https://github.com/libjxl/libjxl). The TrueType hinting follows [FreeType](https://freetype.org): portions of
131
129
  this software are copyright © 2026 The FreeType Project (www.freetype.org). All rights reserved. See
132
130
  [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for the licenses.
133
-
134
- ---
135
-
136
- Questions? Join the [Discord server](https://discord.gg/8hPrwAH).
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  /**
2
2
  * @packageDocumentation
3
+ * @document ../guides/Choosing ImageScript.md
4
+ * @document ../guides/Coming from Jimp.md
5
+ * @document ../guides/Generate favicons.md
6
+ * @document ../guides/Shrink images before upload.md
7
+ * @document ../guides/Social cards for static sites.md
3
8
  * @document ../guides/Migrating to 4.0.md
4
9
  */
5
10
  import { BinaryData } from './util/mem.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imagescript",
3
- "version": "4.0.0-rc.6",
3
+ "version": "4.0.0",
4
4
  "description": "Pure TypeScript image processing that runs everywhere",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",