Skip to content

Latest commit

 

History

History
103 lines (86 loc) · 7.69 KB

README.md

File metadata and controls

103 lines (86 loc) · 7.69 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-31 with Node.js v24.22.1 on AMD EPYC 9V45 96-Core Processor, ImageScript 3.13.1.

ImageScript 3 ImageScript 1 Jimp image-js PureJsImage Photon sharp jsquash @napi-rs/canvas
decode JPEG 20.2 10.5 9.98 8.43 11.8 31.9 103 – 77.0
decode PNG 48.5 33.9 27.8 13.3 19.0 58.9 75.1 – 71.2
decode WebP (lossy) 18.3 – – – 15.2 15.8 53.3 – 91.4
encode JPEG (quality 80) 25.6 30.0 4.08 14.2 10.5 14.9 81.8 – 57.6
encode PNG 8.23 6.42 6.29 4.83 2.56 15.0 10.1 – 2.84
encode WebP (lossless) 1.16 – – – 0.59 35.6 0.99 – 3.01
decode AVIF 6.73 – – – 0.97 – 16.4 6.96 25.9
decode JPEG XL 3.75 – – – fails – – 4.14 22.9
encode AVIF (quality 60) 0.33 – – – 1.15 – 0.72 0.65 –
encode JPEG XL (quality 90) 0.67 – – – – – – 0.38 –
resize to half 113 516 112 17.7 25.4 29.7 186 – 387
rotate by 30° 34.5 10.4 2.82 2.08 3.29 7.75 39.0 – 47.6
blur (radius 5) 23.0 – 0.02 2.44 – 11.3 108 – 91.1
composite an overlay 763 806 53.1 201 – 268 283 – 739
crop 1,207 956 85.6 110 150 334 1,619 – 2,097
clone 1,627 1,275 1,050 1,274 1,836 628 1,710 – 836
render text 3,985 88.9 – – – – 3,394 – 4,677
render SVG 9.41 fails – – – – 42.1 – 158
decode animated GIF 25.0 12.7 – – – – 22.2 – –
encode animated GIF 7.02 1.96 – – – – 1.39 – –

Encoded sizes:

ImageScript 3 ImageScript 1 Jimp image-js PureJsImage Photon sharp jsquash @napi-rs/canvas
photo PNG 2.0 MB 3.0 MB 2.7 MB 2.8 MB 2.1 MB 2.8 MB 2.8 MB – 2.1 MB
photo JPEG 218 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 795 kB 802 kB 2.0 MB 736 kB 811 kB 2.2 MB 718 kB – 1.0 MB
graphic JPEG 276 kB 314 kB 315 kB 315 kB 286 kB 314 kB 275 kB – 276 kB
graphic WebP 277 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.13.1 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.