Skip to content

Latest commit

 

History

History
103 lines (86 loc) · 7.68 KB

README.md

File metadata and controls

103 lines (86 loc) · 7.68 KB

ImageScript benchmark

How ImageScript compares to other image libraries for Node.js: speed, file sizes and what installing each takes. ImageScript is plain JavaScript with no dependencies, so it runs wherever JavaScript does, like Jimp, image-js and PureJsImage; sharp and @napi-rs/canvas wrap native libraries (libvips, Skia), Photon and ImageScript 1 are WebAssembly, and so is jsquash (Squoosh's libavif and libjxl, for AVIF and JPEG XL).

Install size of each library

Decoding and encoding speed

AVIF and JPEG XL decoding and encoding speed

Speed of image operations

Text and SVG rendering speed

Animated GIF decoding and encoding speed

Encoded file sizes

Numbers

Operations per second (more is faster), measured 2026-10-30 with Node.js v24.22.1 on INTEL(R) XEON(R) PLATINUM 8573C, ImageScript 3.12.0.

ImageScript 3 ImageScript 1 Jimp image-js PureJsImage Photon sharp jsquash @napi-rs/canvas
decode JPEG 13.3 6.20 6.17 5.76 7.92 23.7 67.8 – 54.6
decode PNG 27.7 23.9 16.9 7.93 12.3 38.5 45.3 – 48.9
decode WebP (lossy) 11.4 – – – 9.93 12.2 34.9 – 62.2
encode JPEG (quality 80) 14.4 19.4 2.84 9.43 7.83 9.20 52.8 – 38.1
encode PNG 7.26 4.07 4.05 2.87 1.78 10.4 7.33 – 2.08
encode WebP (lossless) 0.89 – – – 0.40 24.6 0.71 – 2.22
decode AVIF 4.18 – – – 0.59 – 12.2 4.87 16.2
decode JPEG XL 2.33 – – – fails – – 2.72 15.6
encode AVIF (quality 60) 0.21 – – – 0.82 – 0.41 0.45 –
encode JPEG XL (quality 90) 0.43 – – – – – – 0.25 –
resize to half 79.2 301 75.7 9.79 15.7 20.6 116 – 379
rotate by 30° 20.6 5.93 1.83 1.37 1.99 4.28 30.1 – 34.6
blur (radius 5) 15.4 – 0.01 1.59 – 6.12 62.8 – 50.0
composite an overlay 414 447 36.7 111 – 164 206 – 351
crop 644 494 60.9 59.2 96.4 209 1,118 – 1,154
clone 834 614 674 610 834 355 906 – 373
render text 1,987 64.8 – – – – 1,899 – 3,398
render SVG 6.52 fails – – – – 28.3 – 87.4
decode animated GIF 15.5 8.74 – – – – 14.5 – –
encode animated GIF 4.41 1.36 – – – – 0.95 – –

Encoded sizes:

ImageScript 3 ImageScript 1 Jimp image-js PureJsImage Photon sharp jsquash @napi-rs/canvas
photo PNG 2.2 MB 3.0 MB 2.7 MB 2.8 MB 2.1 MB 2.8 MB 2.8 MB – 2.1 MB
photo JPEG 217 kB 257 kB 260 kB 260 kB 222 kB 257 kB 218 kB – 218 kB
photo WebP 1.3 MB – – – 2.1 MB 1.7 MB 1.2 MB – 1.4 MB
graphic PNG 891 kB 802 kB 2.0 MB 736 kB 811 kB 2.2 MB 718 kB – 1.0 MB
graphic JPEG 275 kB 314 kB 315 kB 315 kB 286 kB 314 kB 275 kB – 276 kB
graphic WebP 557 kB – – – 758 kB 856 kB 239 kB – 631 kB
animation GIF 825 kB 1.3 MB – – – – 720 kB – –
photo AVIF 93 kB, 40.9 dB – – – 992 kB, 32.7 dB – 91 kB, 40.6 dB 80 kB, 40.2 dB –
photo JPEG XL 245 kB, 44.5 dB – – – – – – 230 kB, 44.1 dB –
graphic AVIF 147 kB, 41 dB – – – 709 kB, 38.5 dB – 114 kB, 38.7 dB 136 kB, 40.5 dB –
graphic JPEG XL 230 kB, 43.4 dB – – – – – – 194 kB, 41.9 dB –
ImageScript 3 ImageScript 1 Jimp image-js PureJsImage Photon sharp jsquash @napi-rs/canvas
kind JavaScript WebAssembly JavaScript JavaScript JavaScript WebAssembly native (libvips) WebAssembly native (Skia)
package imagescript@3.12.0 imagescript@1.3.1 jimp@1.6.1 image-js@1.7.1 purejsimage@0.17.0 @silvia-odwyer/photon-node@0.3.4 sharp@0.35.5 @jsquash/avif@2.1.1 @jsquash/jxl@1.3.0 @napi-rs/canvas@1.0.11
install size 2.4 MB 6.7 MB 26.8 MB 47.8 MB 6.7 MB 2.3 MB 20.3 MB 14.2 MB 35.0 MB
packages 1 1 64 55 1 1 6 3 2

Method

  • Inputs (in inputs/, sources in inputs/SOURCES.md): a 1920×1080 photo (JPEG, and made from it when the benchmark starts, PNG, lossy WebP, AVIF by sharp (libaom) and JPEG XL by jsquash (libjxl, effort 7), both at the qualities below), a 1434×1434 graphic with transparency (PNG), a 445×445 diagram with transparency placed on the photo (PNG), a 300×300 GIF with 101 frames.
  • AVIF and JPEG XL are encoded at the same nominal quality (60 and 90); as the libraries' scales differ, the file sizes come with their PSNR (of the color over black, decoded by libavif and libjxl). PureJsImage's AVIF encoder has no quality option, and its JPEG XL decoder doesn't support everything libjxl's files use, which shows as failing. jsquash only encodes and decodes AVIF and JPEG XL (it gets the other inputs as pixels); @napi-rs/canvas decodes both with Skia's codecs, but doesn't encode them.
  • Rendering: "The quick brown fox jumps over the lazy dog, 0123456789" in Source Sans 3 at 64px, and tests/svgs/features.svg (gradients, clipping, CSS) at 1920 pixels wide. Jimp, image-js, PureJsImage and Photon can't render TrueType/OpenType fonts or SVGs; ImageScript 1 crashes on this SVG; @napi-rs/canvas (Skia's SVG module) ignores its CSS, so it draws a little less.
  • Every operation starts from the same decoded image and returns a new one: libraries that change images in place clone first, sharp runs a pipeline from raw pixels back to raw pixels, PureJsImage (which has no decoded images) one from a BMP back to a BMP, @napi-rs/canvas draws into a new canvas. PureJsImage has no blur, composite, rendering or animated GIFs.
  • Where the library lets you choose, resizing is bilinear (ImageScript 1 only has nearest neighbor), blurring is gaussian with a radius or sigma of 5, rotating grows the image to fit. Each library uses its own defaults otherwise, e.g. its PNG compression level.
  • Threads: ImageScript uses worker threads where they pay off (the processors available, at most 8), and sharp gets as many (sharp.concurrency(); its default on glibc Linux without jemalloc, like on CI, is one). The other libraries run on one thread (jsquash turns its threaded builds off in Node).
  • tinybench, at least 1.5 seconds and 3 runs per measurement, every library in its own process.
  • The release workflow runs the benchmark for every release and commits the results, on a GitHub Actions runner; runners vary, so compare libraries within one run rather than between runs.
  • Install sizes: npm install <library> in an empty project, the apparent size of node_modules.

Run it: npm install in this directory, then node run.js (on an idle machine; IMAGESCRIPT=local measures this checkout after npm run build instead of the version from npm), node installs.js and node report.js.