Skip to content

PureJsImage v0.19.0

Latest

Choose a tag to compare

@a-r-d a-r-d released this 27 Nov 14:05
· 6 commits to main since this release

Upgrade notes

  • Lossy WebP decoding now uses bilinear chroma upsampling and matches libwebp exactly on the
    tested still images. Decoded pixels differ slightly from 0.18.0, most on saturated edges.
  • The lossy WebP encoder writes different, smaller files for the same quality: 10% to 23%
    smaller at equal PSNR and SSIM in our tests. The quality scale is unchanged. Lossy WebP with
    transparency also compresses its alpha channel now.
  • PNG output from 8-bit RGB or RGBA pixels is an indexed PNG when the image has 256 or fewer
    colors and that file is smaller. The pixels are the same; the file bytes differ.
  • A resize that cannot crop or pad now runs before a flip, flop, 90-degree rotation or EXIF
    auto-orient placed ahead of it, so the orientation step moves the smaller image.
  • New APIs: image.gif(), image.ico(), encode('gif'), open(input, { animated: true }) for
    animated GIF and WebP, { frame: n } for any frame, openGifAnimation() and
    encodeGifAnimation() in purejsimage/codecs/gif, openWebpAnimation() and
    encodeWebpAnimation() in purejsimage/codecs/webp, the optional
    purejsimage/accelerators/wasm/resize accelerator, and the Node-only, default-off threads
    option for parallel PNG compression.
  • WASM stays opt-in. Applications that do not register an accelerator run the same TypeScript
    code paths as before.

Added

  • GIF output: image.gif() and encode('gif'). Images with 256 or fewer colors keep their exact
    colors. Other images get a Wu palette refined with three k-means passes, and Floyd-Steinberg
    dithering in serpentine order that fades out where the source already has edges or texture
    (dither from 0 to 1, default 1). Alpha below 128 becomes transparent. On 600 px photos and a
    smooth gradient, plain PSNR is 0.4 to 2.4 dB below Sharp/libimagequant and PSNR after a 3x3 blur
    matches or beats it, with files from 16% smaller to 8% larger. The 2400x3000 portrait resized to
    800 px and written as GIF takes 519 ms against 569 ms for ImageScript and 961 ms for Sharp.

  • Animated GIF: open(input, { animated: true }) runs crop, resize, rotate, flip, and flop on
    every frame and writes an animated GIF with the source delays and loop count. Each frame stores
    only its changed rectangle, with unchanged pixels inside it written as transparent, and the
    encoder chooses each frame's disposal one frame later so pixels that turn transparent are
    cleared. { frame: n } now selects any frame. openGifAnimation() and encodeGifAnimation() in
    purejsimage/codecs/gif read and write frames directly. A 36-frame 480x270 photographic GIF
    resized to 240 px takes 296 ms against 371 ms for ImageScript and 3,765 ms for Sharp; the
    70-frame CC0 GIF resized to 100 px takes 58 ms against 72 and 85 ms.

  • Optional WASM resize accelerator at purejsimage/accelerators/wasm/resize. Register
    wasmResizeAccelerator in the accelerators list to run Lanczos 3 resizing and the box
    pre-shrink for rgb8 and rgba8 images in Rust/WASM, including premultiplied alpha and opaque
    RGBA. Output is byte-identical to the TypeScript resize in the scalar and SIMD builds. It works
    on the same bounded rows as the TypeScript kernel and falls back to TypeScript for other kernels
    and formats, or if WASM fails during a resize, without repeating rows. Applications that do not
    register it are unchanged. Each build is about 32 KB (11 KB gzipped). With the JPEG, PNG and WebP
    accelerators also registered, resizing a 12 MP JPEG to 1200 px takes 173 ms instead of 246 ms,
    and the 1024 px MMS JPEG workflow 169 ms instead of 250 ms.

  • Animated WebP: open(input, { animated: true }) decodes every frame of an animated WebP,
    applying alpha blending and disposal, and webp() writes animated WebP. Each output frame encodes
    the rectangle that changed, at even offsets; when every changed pixel is opaque the frame blends
    with transparent unchanged pixels, otherwise it replaces the rectangle exactly. Durations and
    the loop count carry over unless loop is set. { frame: n } selects one frame, and
    openWebpAnimation() and encodeWebpAnimation() in purejsimage/codecs/webp read and write
    frames directly. Lossless frames decode exactly like libwebp, including partial-alpha blending.
    The 36-frame lossy WebP resized to 240 px takes 461 ms against 645 ms for ImageScript and
    292 ms for Sharp; converting it to GIF takes 804 ms against 1,187 and 6,920 ms.

  • ICO output: image.ico({ sizes }) writes one entry per size, 16, 32, and 48 by default, up to
    256. Each size fits the image on a transparent square with Lanczos resizing. Sizes below 256 are
    32-bit BMP entries with AND masks; 256 is a PNG entry.

  • The benchmark suite adds a gif profile with generated 36-frame photographic and 24-frame
    transparent sticker GIFs, animated resize and round-trip workflows, last-frame decoding, and
    photo and logo GIF output, plus a favicon workflow in the ico profile. Every GIF frame of the
    output is decoded with omggif during validation. The performance page and README now publish
    GIF speed and peak memory charts against Sharp, ImageScript, and Jimp.

  • open(input, { threads }) turns on parallel PNG compression in Node. It is off by default; the
    default single-threaded path, its output bytes, speed and memory are unchanged. With
    threads: 4, Node compresses filtered scanlines in 384 KiB chunks on its libuv thread pool, at
    most four jobs per image, each primed with the previous chunk's last 32 KiB so the joined zlib
    stream compresses almost as well. Allow roughly 1.5 MiB of extra memory per job. Pixels are
    identical and files stayed within 1% of the default size on the benchmark images. AVIF to PNG
    takes 319 ms instead of 475 ms with threads: 4. Images with at most 384 KiB of scanlines,
    single-threaded runtimes and browsers use the sequential compressor. The benchmark suite adds a
    separate purejsimage-threads engine for this mode.

Changed

  • Still images run their transforms in the pipeline executor's own loop again instead of the
    shared helper added for animation. With the helper, V8 discarded and recompiled the JPEG encoder
    and TIFF reader code, and the TypeScript 4000x3000 TIFF to JPEG workflow ran about 5% slower;
    the restored loop measured 3.1% faster in a same-path comparison, with no change on the other
    workflows checked.

  • The benchmark hillclimb runner now runs the base and candidate builds from one shared path.
    Running them from different directories had shifted identical code by up to 16% in peak memory
    and 13% in time on some workflows.

  • The lossy WebP encoder now uses four more VP8 tools: a normal loop filter on textured images
    at a level set from the quantizer, two segments that give smooth-gradient macroblocks a finer
    quantizer, coefficient probabilities learned from the start of each frame, and skip flags for
    macroblocks with no coefficients when the whole frame fits in that sample. The quality scale
    is unchanged. At equal PSNR and SSIM, files are on average 10.5% and 16.8% smaller on six
    photos and 20.5% and 23.0% smaller on five graphics. The transparent logo at quality 75 drops
    from 12,222 to 9,876 bytes while PSNR rises from 42.16 to 42.95 dB; Sharp/libwebp still writes
    6,088 bytes at 47.51 dB. Encoding is also faster: the logo takes 64 ms instead of 72 ms in
    TypeScript and 48 ms instead of 67 ms with the WASM accelerators, and the 12 MP photo 561 ms
    instead of 574 ms and 248 ms instead of 263 ms.

  • The optional WASM accelerators are faster again, with output unchanged. With all of them
    registered:

    • resizing the transparent 1200x480 logo PNG to 800 px takes 11 ms instead of 27 ms, against
      11.6 ms for Sharp single-thread, because the resize accelerator skips fully transparent spans
      and reuses results for repeated pixel groups. In Node the PNG encoder also lets deflate buffer
      one filtered block, so the TypeScript engine takes 41 ms instead of 44 ms;
    • resizing a 12 MP JPEG to 1200 px takes 113 ms instead of 121 ms, from a shared bit buffer for
      short Huffman codes, symmetric terms in the half-scale inverse DCT, and quantizing four
      coefficients at a time in the SIMD JPEG encoder;
    • resizing the lossy 1600x2000 WebP portrait to a JPEG takes 92 ms instead of 105 ms, from
      packed arithmetic-decoder state, fixed mode-tree offsets, skipping loop-filter edges with no
      change, and inverse transforms on four coefficients at once;
    • applying EXIF orientation 6 to a JPEG takes 79 ms instead of 92 ms.
  • Lossy WebP decoding now uses bilinear chroma upsampling and BT.601 fixed-point color
    conversion, in TypeScript and in the optional WASM accelerator. Decoded pixels now match libwebp
    exactly on all 224 lossy still images in the Imazen WebP corpus and on the five lossy benchmark
    images; before, 48 corpus images matched and the rest averaged 42 dB PSNR. Nearest-neighbor
    chroma had shown most on saturated edges. The TypeScript decoder is about 1% slower, and PNG
    files written from decoded WebP photos can be a few percent larger because the chroma is
    smoother.

  • The lossy WebP encoder now chooses a prediction mode for every macroblock: the four 16x16 luma
    modes, the ten 4x4 luma modes and the four chroma modes, scored by distortion plus estimated
    bits. Before, every block used DC prediction. On six test images at quality 50, 75 and 90,
    files are 1.4% to 24.7% smaller with higher PSNR and SSIM in all 18 cases; the transparent logo
    at quality 75 drops from 15,034 to 12,222 bytes. Encoding a 12 MP photo is about 10% slower in
    TypeScript; the extra working memory is one macroblock row.

  • In Node, PNG decoding inflates image data with node:zlib in 64 KiB chunks instead of the
    web DecompressionStream, which cut the hand-offs on the 100 MP test image from 24,698 to
    6,386. Browsers are unchanged. With only TypeScript codecs, resizing a 12 MP PNG takes 269 ms
    instead of 297 ms with 6% lower peak memory.

  • The optional WASM accelerators are faster. With all of them registered:

    • resizing a 12 MP JPEG to 1200 px takes 121 ms instead of 173 ms, from faster Huffman
      lookups, half-scale inverse DCT and 4:2:2 conversion in the JPEG decoder and SIMD vertical
      filtering in the resize accelerator, with output still identical to TypeScript;
    • the 100 MP PNG downscale takes 641 ms instead of 893 ms with 6% lower peak memory;
    • resizing the lossy 1600x2000 WebP portrait takes 105 ms instead of 152 ms with 12% lower peak
      memory, because the WebP accelerator now decodes a whole macroblock row per call.
  • The optional JPEG WASM accelerator now decodes progressive JPEG: DC and AC first and
    refinement scans, end-of-band runs, and restart intervals, at full, 1/2 and 1/4 scale. It keeps
    compact coefficient planes and reconstructs rows in bounded bands, like the TypeScript decoder,
    and the pixels are identical. If WASM fails, TypeScript finishes the rows that remain. Resizing
    the progressive 12 MP test JPEG to 1200 px on the WASM engine takes 264 ms instead of 554 ms.
    Progressive crops and 1/8-scale decodes still use TypeScript.

  • The optional WebP WASM accelerator now runs VP8 coefficient decoding, prediction, inverse
    transforms and loop filtering, and VP8L entropy decoding for streams without a color cache.
    Decoded pixels are unchanged. Resizing the 1600x2000 lossy WebP portrait to a JPEG takes 152 ms
    instead of 227 ms with 14% lower peak memory, and the lossy photo to PNG 110 ms instead of 133 ms.
    The scalar module grew from 9 KB to 27 KB (4 KB to 11 KB gzipped).

  • PNG CRC checks switch to an eight-bytes-at-a-time table once 256 KiB has been checked. Small
    PNGs keep the byte loop, which is faster before V8 optimizes the larger loop. The optional PNG
    WASM decoder also reads the previous row in place instead of copying it for each row.

  • GIF decoding reads every frame descriptor up front and composites frames on one canvas, with
    disposal methods 0 to 3. LZW data is gathered from its sub-blocks before decoding, codes are
    read with one 16-bit refill, and opaque pixels are written as 32-bit values. Selecting a frame
    skips frames hidden behind a later full-canvas frame without transparency. Opening an animated
    GIF without animated or frame still fails; the error now names both options.

  • PNG output from 8-bit RGB or RGBA pixels is now an indexed PNG when the image has 256 or fewer
    colors and the indexed file is smaller. The pixels are the same. The encoder compresses the RGB
    or RGBA stream and an 8-bit palette-index stream side by side, stops the index stream when a
    257th color appears, and writes the smaller complete file. The logo crop benchmark now writes
    3,611 bytes instead of 5,645, the 200 x 200 GIF frame 472 bytes instead of 1,173, and the
    256-color TIFF 20,668 bytes instead of 46,502. Compressing twice adds about 1 ms to those
    conversions. Photos usually need a 257th color in their first rows; Earthrise, whose top half
    is almost all black, converts in 224 ms instead of 217 ms. Until the encoder knows the color
    count, it holds compressed output in memory instead of writing it to the sink. Opaque indexed
    files decode as rgb8. Grayscale and 16-bit output are unchanged. Pass
    png({ palette: false }) to always write grayscale, RGB or RGBA.

  • Resizing RGBA images with Lanczos 3 is faster with identical output. Each pair of neighboring
    output pixels now shares one read and premultiplication of every source pixel they both use,
    from a coefficient table capped at 512 KiB. A 4000 x 3000 transparent PNG resized to 2048 px
    wide and saved as JPEG takes 786 ms instead of 873 ms, and the transparent logo resize to PNG
    is 10% faster.

  • Lossy WebP with alpha and lossless WebP convert to PNG faster with identical output. WebP copies
    compressed alpha straight from each decoded lossless row into the output, the lossless decoder
    handles its first predictor row outside the hot loop, and PNG adaptive filtering keeps the
    Average residuals it computes while scoring a row after an Average row. The 800 x 600 lossy
    WebP with alpha converts to PNG in 68 ms instead of 78 ms, and the 386 x 395 lossless WebP in
    31 ms instead of 36 ms.

  • The optional JPEG WASM decoder now handles half- and quarter-resolution decoding and reduced
    4:4:4 crops, which used to fall back to TypeScript. It also uses a faster full-resolution inverse
    DCT and exact integer color conversion, and refills compressed input between MCUs, so its WASM
    memory for a 4000 x 3000 photo is 576 KiB instead of 5.1 MiB. With wasmJpegAccelerator
    registered, the 1200-pixel JPEG resize benchmark takes 244 ms instead of 437 ms (TypeScript:
    448 ms), JPEG crop and resize 273 ms instead of 464 ms, and the 24-megapixel photo pipeline 379 ms
    instead of 660 ms. Decoded pixels are unchanged, and the decoder .wasm files are about 20%
    smaller.

  • The optional PNG WASM accelerator is faster than the TypeScript path again. It rebuilds Paeth rows
    with SIMD for four-byte pixels, scores adaptive filters with SIMD, reuses Paeth residuals, skips
    all-zero rows, writes inflated data straight into WASM memory and reuses output blocks that the
    pipeline releases. With wasmPngAccelerator registered, PNG resize takes 275 ms instead of 375 ms
    (TypeScript: 300 ms), PNG crop and resize 225 ms instead of 309 ms, JPEG to PNG 123 ms instead of
    231 ms, and the 100-megapixel downscale 1115 ms instead of 1252 ms with 194 MiB peak RSS instead of
    208 MiB. Output bytes are unchanged.

  • Rotation by an arbitrary angle is faster with identical output. It samples from a bounded
    96 x 96 RGBA window, copies areas where all four source pixels match, skips transparent margins,
    and reads neighboring temporary tiles together, so the benchmark logo needs 903 tile reads instead
    of 2,920. Rotating the 1200 x 480 transparent logo by 17 degrees to JPEG takes 65 ms instead of
    168 ms, with 12% lower peak RSS.

  • PNG decoding, RGBA resizing and JPEG encoding are faster with identical output. PNG Paeth rows
    are rebuilt one byte lane at a time and swapped instead of copied. The RGBA resize reads each
    pixel as one 32-bit word, takes alpha scales from a table and adds four vertical taps per pass.
    The JPEG encoder blends alpha in integer math, rounds quantized coefficients faster and writes
    common AC codes with their magnitude bits from one 8 KiB table. A 4000 x 3000 transparent PNG
    resized to 2048 px wide and saved as JPEG takes 872 ms instead of 1106 ms, a 2048 x 2048 noise PNG
    converts to JPEG in 332 ms instead of 373 ms, PNG crop and resize is 15% faster, and JPEG resize
    is 3 to 5% faster.

  • PNG adaptive filtering and lossless WebP encoding and decoding are faster with identical output.
    PNG Paeth scoring uses a 256 KiB lookup table that loads with the PNG encoder. Lossless WebP
    decoding skips channels whose Huffman code has one symbol. The lossless encoder sizes its LZ77
    token storage from runs of equal pixels, skips zero pixels when it chooses color transforms,
    reuses palette indices, and predicts and packs the lossy alpha plane in one pass. PNG to lossless
    WebP takes 100 ms instead of 127 ms, lossy WebP to PNG 146 ms instead of 162 ms, and the
    transparent logo's lossy WebP encode 72 ms instead of 89 ms with the same 16,264-byte file.

  • A resize now runs before a flip, flop, rotation by a multiple of 90 degrees, or EXIF
    auto-orient that comes ahead of it in the pipeline, so the orientation step moves the smaller
    image. This applies when the resize cannot crop or pad: a single dimension, or fit set to
    fill, inside or outside, with any kernel except nearest. A JPEG rotated 90 degrees and
    resized also gets the same reduced-resolution decode as a plain resize. On the 12-megapixel
    benchmark JPEG, rotate 90 then resize to 1200 px wide takes 572 ms instead of 1013 ms, with
    154 MiB peak RSS instead of 192 MiB. A 2.16-megapixel phone JPEG with EXIF orientation 6
    auto-orients and resizes to 800 px in 90 ms instead of 153 ms. PNG and other inputs without
    reduced-resolution decoding give identical pixels. JPEG output differs slightly because of the
    reduced-resolution decode, as a plain JPEG resize already does.

  • Resizing RGBA images with transparent areas is faster with identical output. The Lanczos 3
    horizontal pass skips output pixels whose source taps are all transparent, and reuses a row's
    filtered values for 32-pixel groups whose source bytes match the previous row. PNG adaptive
    filtering also skips scoring over all-zero margins. The 1200 x 480 transparent logo resizes to
    800 px PNG in 37 ms instead of 65 ms, and peak RSS is 4% lower.

  • Lossy WebP (VP8) decoding is faster with identical pixels. The boolean decoder refills 16 bits
    at a time and reads coefficient signs without a branch, empty and DC-only blocks skip the full
    inverse transform, loop-filter work with zero adjustment is skipped, and full-width RGBA bands go
    to the pipeline without another copy. The 1600 x 2000 benchmark photo resizes to JPEG in 239 ms
    instead of 288 ms, with 6% lower peak RSS. Partitions that start with 0xFF keep the previous
    byte-at-a-time decoder.

  • Baseline JPEG decoding is faster with identical pixels. Short AC Huffman codes decode together
    with their signed value from one lookup, sparse IDCT rows accumulate in locals, 4:2:0 color
    conversion shares chroma interpolation between neighboring pixels, and the encoder quantizes
    coefficients as it writes them. EXIF auto-orient of the 2.16 MP benchmark JPEG takes 151 ms
    instead of 215 ms, JPEG to PNG 240 ms instead of 354 ms, and JPEG crop and resize is 4% faster.
    JPEG output bytes are unchanged.

  • Lossless WebP decoding is faster with identical pixels. Huffman codes up to 8 bits decode from
    one lookup table, the LZ77 history is sized from the largest distance the stream's codes can
    reach instead of always 1 MiB pixels, and predictor loops are chosen once per tile. The
    400 x 301 benchmark image decodes and converts to PNG in 42 ms instead of 52 ms, and allocates
    about 0.5 MB less history.

  • EXIF auto-orient of a JPEG is 48% faster: 220 ms instead of 421 ms for the 2.16 MP
    auto-orient-6 benchmark, with 5% lower peak RSS. The orientation transform reads each
    spooled tile once, copies RGB pixels in runs instead of one small copy per pixel, and reuses
    an output band after the encoder releases it. The JPEG encoder copies RGB and grayscale rows
    in bulk and uses a factored forward DCT. Coefficients near a rounding boundary are recomputed
    in the original order, so JPEG output bytes are unchanged. Plain JPEG resize to JPEG is 3%
    faster too.

  • Progressive JPEG decoding is faster: the 12 MP progressive resize benchmark takes 600 ms
    instead of 735 ms. AC scans decode runs of blocks between restart and buffer-refill points
    without returning to the async scan loop, common Huffman codes decode from one 8-bit lookup,
    all scans share one entropy buffer, and 4:2:0 color conversion shares chroma interpolation
    between neighboring pixels. Coefficients stay in compact Int16 storage and pixels are still
    rebuilt in bounded MCU rows. Output is unchanged.

  • AVIF decoding is faster with identical pixels. On the 1204 x 800 benchmark photo, full decode
    to PNG takes 495 ms instead of 674 ms, resize to JPEG 322 ms instead of 515 ms, and crop and
    resize 239 ms instead of 437 ms, each measured in 21 alternating pairs. Peak RSS is up to 5%
    lower. The AV1 decoder reuses sums and scratch rows in the deblocking, Wiener and self-guided
    restoration filters, restores only the strips a crop needs, computes the radius-2 self-guided
    pass only on rows it uses, simplifies symbol renormalization and coefficient contexts, batches
    range-checked inverse transforms, shares chroma interpolation between neighboring pixels, and
    no longer allocates palette context when screen content tools are off. When the decoder reports
    that every pixel is opaque, the first resize filters RGB only and skips the alpha channel; its
    output bytes match the RGBA path.

  • PNG encoding is faster with byte-identical files. Adaptive filtering keeps the Paeth residuals
    it computes while scoring a row instead of filtering the row again when Paeth wins, uses a 4 KiB
    Paeth lookup table, and writes all-zero rows without scoring. JPEG to PNG on the 2400 x 2400
    benchmark photo takes 356 ms instead of 446 ms, and AVIF to PNG is 7% faster.

  • Registering the JPEG XL codec, for example through allCodecs, no longer loads its VarDCT,
    animation, native-sample and encoder code. That code loads on the first JPEG XL decode or encode
    that needs it. Since 0.17.0 the codec had grown to 1.7 MB of JavaScript that loaded with
    allCodecs, so JPEG, PNG, WebP, AVIF and TIFF workflows paid for it without reading JPEG XL. On
    eight web codec benchmark workflows, peak RSS is now 29 to 58 MiB lower, for example 170.7 MiB
    instead of 200.0 MiB on the 24-megapixel photo pipeline. Importing the library with allCodecs
    takes 79 ms instead of 151 ms. The first JPEG XL encode in a process takes about 50 ms longer
    because it loads the encoder then. Code that registers only the codecs it uses, such as
    [jpegCodec, pngCodec] or allWebCodecs, was not affected. The minified Core + JPEG XL bundle
    grows by 5.3 KB and the JPEG XL specialized APIs bundle by 6.8 KB, because a single-file bundle
    wraps each module that loads later.

  • Registering the AVIF codec, including through allWebCodecs, no longer loads the AV1 encoder or
    unpacks the AV1 quantization matrices. The encoder loads on the first AVIF encode, and the
    matrices on the first decode that uses them. Importing allWebCodecs takes 14.2 MiB instead of
    16.8 MiB of extra RSS, and allCodecs 20.1 MiB instead of 23.6 MiB. Peak RSS on JPEG, PNG and
    WebP benchmark workflows is about 3 to 10 MiB lower.

  • Registering codecs now loads only their format detection and header code. Pixel decoding,
    encoding and metadata parsing for JPEG, PNG, WebP, AVIF, TIFF, JPEG 2000, JPEG XL, BMP, GIF,
    HDR, ICO, Netpbm, QOI and TGA load on first use. Importing the library with allCodecs adds
    8.2 MiB of RSS and takes 19 ms instead of 28.2 MiB and 80 ms, and allWebCodecs adds 4.5 MiB in
    8 ms instead of 13.5 MiB in 43 ms. Peak RSS on the web codec benchmark workflows is 7% to 15%
    lower, for example 145 MiB instead of 169 MiB on the 24-megapixel photo pipeline and 135 MiB
    instead of 159 MiB on the 1200-pixel JPEG resize. In Node, fs/promises loads only when
    temporary files are turned on. Output is unchanged. The first decode or encode of a format in a
    process loads its module, which adds about 5 to 10 ms for JPEG and PNG. On its own, the split
    made small images 1 to 2.5 ms slower per warm run. The PNG and lossless WebP changes in the next
    entry more than make up for it. Large workflows are within 1%.

  • PNG decoding, PNG adaptive filtering and lossless WebP decoding are faster with identical
    output. PNG decoding adds the four bytes of a Sub-filtered RGBA pixel in one 32-bit operation,
    adaptive filtering finds all-zero row margins four bytes at a time, and the lossless WebP bit
    reader reads one 32-bit word per lookup instead of refilling a byte at a time. Compared with the
    code before lazy codec loading, the 400 x 301 lossless WebP to PNG benchmark takes 38 ms instead
    of 41 ms, the transparent logo resize and PNG to JPEG benchmarks are 1% faster, and all three
    use 11% to 14% less peak RSS.

  • JPEG XL lossless effort 7 is 3.4 to 8.1 times faster on the eight 1-megapixel comparison images:
    182 s instead of 819 s in total, with files 0.29% larger in total. Effort 7 now trains predictor
    trees once on four times the default samples, and also on the default samples only when that
    pass keeps no tree. It skips the 256-color palette search for opaque images, document patches
    when flat screenshot patches already shrink the image, flat patches with local color, local color
    groups, and extra hybrid integer splits on groups over 65,536 residuals. Effort 9 keeps all of
    these searches. See "Lossless effort 7 and 9" in docs/jpeg-xl.md.

Fixed

  • Lossy WebP output with transparency now compresses its alpha channel. The encoder wrote alpha
    as raw bytes, one byte per pixel, so the 1200 x 480 transparent benchmark logo at quality 80 was
    590,616 bytes. It now writes the alpha plane as a lossless VP8L stream, the method libwebp uses
    by default, and the same logo is 16,264 bytes. Alpha values stay exact. When compression would
    not make the alpha plane smaller, the encoder keeps raw alpha. Encoding the logo takes 87 ms
    instead of 58 ms and peak RSS is about 6 MiB higher.
  • JPEG XL lossy effort 7 on screenshots and text no longer takes several minutes per megapixel.
    Its exact palette check runs the lossless effort-7 search, which took over 400 s on a
    1-megapixel RGBA text image and now takes 65 s.
  • Keep a sampled GRAY ICC profile, such as Photoshop's Dot Gain profiles, on a grayscale JPEG in
    lossless keepIcc().jpegxl() output. The JPEG decoder emits equal RGB channels, which now fold
    back to gray samples with the exact profile. These encodes failed with INVALID_INPUT before.
    RGB samples with unequal channels still cannot carry a GRAY profile and fail with
    INVALID_INPUT.
  • Check a kept ICC profile's compressed stream when the JPEG XL encoder is created. When the
    stream is over 4 MiB, a matrix and curve profile now writes its equal structured color, and other
    profiles fail with LIMIT_EXCEEDED before any rows. Both failed in finish() after every row
    was written before.

Testing, CI and docs

  • The web benchmark worker now runs one last-resort major garbage collection between the warmup
    and the measured run. It frees warmup garbage, shrinks V8's young generation and returns pooled
    heap pages. Three plain collections used to leave 15 to 30 MiB of freed warmup memory resident,
    and how much depended on how V8 had sized its heap, so peak RSS for identical runs split into two
    clusters about 14 MiB apart. On the 1200-pixel JPEG resize, 18 peak RSS samples now span 101 to
    110 MiB instead of 125 to 146 MiB, with unchanged wall time. Absolute peaks for JavaScript
    engines are about 30 MiB lower than before, so older and newer peak RSS numbers are not
    comparable. npm run bench:hillclimb now copies the candidate's worker into the base revision
    too, so both sides measure the same way.
  • npm run bench:hillclimb takes --profile for web workloads outside the web-codecs profile,
    such as transforms, standard and webp. It still defaults to web-codecs.
  • The PureJsImage benchmark engine now opens frame 0 on the two workflows that benchmark the first
    frame of an animated GIF, gif-first-frame-png and lambda-logo-gif. Both failed for
    PureJsImage after animated GIF decoding started to require an explicit frame. Pipeline
    workflows can set a frame field for this.
  • The published web codec benchmark is rerun at 4e4a22e0, after the lazy codec loading, the
    JPEG, PNG, WebP, rotation and resize speedups and the faster JPEG and PNG WASM accelerators. The
    README table, website charts and public snapshot use the new run, with the same 143 passing and
    25 unsupported cases. Compared with the previous snapshot, PureJsImage's median wall time across
    workflows fell 5.2% and the WASM configuration's fell 16.0%; the other engines moved -2.1% to
    +1.2%. The run uses the new garbage collection before each measured run, which lowered peak RSS
    for every engine (the other engines by 1.5% to 9.6%), so peak RSS is not comparable with older
    snapshots. With default settings, PureJsImage is faster than ImageScript 4.0.0 on 19 of 21 shared
    workflows and uses less peak RSS on all 21. ImageScript is still faster on the small transparent
    PNG resize (38 ms against 43 ms) and AVIF to PNG (457 ms against 472 ms).
  • AGENTS.md now allows parallel execution only behind the explicit, default-off threads
    option, with capability detection in the runtime adapters, bounded memory per thread, and a
    separate benchmark engine. The single-threaded path stays the default and the main target.
  • The website's X-Ray, HDR, OME-Zarr, and 4D-STEM workers now ignore messages that do not come
    from the page that created them. They share one check with the JPEG XL workbench worker.
  • Local benchmark servers log request errors instead of sending error text and stack traces in
    the HTTP response.
  • The JPEG XL transform-gap fixture script passes its build paths to the shell through quoted
    environment variables, so a checkout path with spaces or shell characters still works.
  • The JPEG XL comparison harness adds ImageScript 4.0.0, a pure TypeScript library, as a subject.
    ImageScript decodes to RGBA8 and encodes lossless and lossy JPEG XL; 16-bit samples, extra
    channels, animation encode, ICC access, region reads and JPEG reconstruction are reported as not
    exposed. Chromium runs use the installed Chrome, each job may take 20 minutes, and reports record
    the machine load average. The published comparison results are not refreshed yet.
  • The web-codecs and competitors benchmark profiles add ImageScript 4.0.0 as an engine, and
    the package size comparison adds its public import. ImageScript runs with its default options,
    except that EXIF orientation is applied only in workflows that ask for it. It passes all 21 web
    codec workflows and all competitor workflows except the HEIC one, which it cannot decode. Its
    metadata workflows decode the full image because it has no header-only reader. Its AVIF decoder
    and encoder use worker threads by default, so its AVIF CPU time is higher than its wall time.
  • The published web codec benchmark is rerun with ImageScript as an eighth engine. The README
    table, website charts and public snapshot use the new run, with 143 passing and 25 unsupported
    cases. The seven other engines keep the same results, and their median wall times moved −4% to
    +3%, with load averaging 4.3. Against the TypeScript PureJsImage path, ImageScript is faster on 8
    of 21 workflows and uses less peak RSS on 4. On the 24 MP photo pipeline it takes 1346 ms and
    334.0 MiB, against 723 ms and 154.3 MiB. It is faster at EXIF auto-orient (161 ms against 410
    ms), AVIF decode and lossless WebP decode. Its JPEG to AVIF encode takes 2395 ms of wall time
    and 8.4 s of CPU, against 949 ms. On the 100 MP PNG downscale its peak RSS is 1268.4 MiB,
    against 204.2 MiB.
  • The web codec and competitor charts size each workflow group and the legend from the number of
    engines, so eight engines no longer overlap the next group's title or the axis labels.
  • Two tiled JPEG XL patch tests now pin streams 2 and 3 bytes larger, from the effort-7 hybrid
    split change. A new test checks that effort 7 still finds document patches on a white text
    page. Pinned libjxl 0.12.0 decodes every sample of the new streams.
  • npm run lint reports no warnings. JPEG XL code replaces non-null assertions with ?? 0 sample
    reads and checked plane reads. JPEG XL encoder and decoder output is unchanged.
  • Development dependencies are updated to clear most npm audit advisories: Astro 7.4.13 for the
    website, Vitest 4.1.12, and aws-cdk-lib 2.278.0 with CDK CLI 2.1149.0 for the Lambda benchmark.
    An override gives archiver readdir-glob 4.0.0. image-js 1.7.0 now resolves colord 2.14.0, so
    its recorded bundle grows by 1.5 KB minified.
  • The root install no longer includes the packages used only by the viewer and scientific
    competitor benchmark lanes (Cornerstone3D, Viv, deck.gl, NiiVue, ITK-Wasm image-io,
    OpenSeadragon, cogeotiff, h5wasm, nifti-reader-js, and npyjs). npm run typecheck:lanes checks
    those harnesses against the pinned installs in benchmark/viewers and
    benchmark/competitors-js, and a new CI job runs it. The root npm audit drops from 54 to 31
    advisories. The ones left come from the pinned Jimp and sharp comparators.
  • The benchmark comparators move from Jimp 1.6.0 to 1.7.0 and from sharp 0.35.3 to 0.35.5, so the
    root npm audit drops from 31 advisories to none. Sharp oracle output in the JPEG, WebP, AVIF,
    and JPEG XL tests is byte-identical. Jimp 1.7.0 moves to zod 4 and file-type 21. Its minified
    bundle grows from 577 KiB to 937 KiB (zod is 376 KiB of it), gzip from 175 KiB to 264 KiB, and
    its installed size from 29.3 MiB to 31.2 MiB. Sharp's wrapper grows by 446 bytes and its
    installed size by 0.5 MiB. Interleaved same-machine reruns of the Jimp smoke, transform, and
    competitor workflows show Jimp importing in 140 to 170 ms instead of about 80 ms, with 4 to 11
    MiB more peak RSS on most workflows and up to 32 MiB more on three. Wall time did not change
    beyond run-to-run noise.
  • The published web codec benchmark is rerun with PureJsImage 0.18.0, Jimp 1.7.0 and sharp
    0.35.5. The README table, website charts and public snapshot use the new run. All 122
    supported cases pass with no invalid output. Against the August 24 run, median wall time moved
    -3% for PureJsImage, +17% for Jimp and +15% for single-threaded sharp. Engines whose versions
    did not change (sharp with default threads, image-js and jSquash) moved -1% to +4%. PureJsImage
    peak RSS on the 24-megapixel photo pipeline is 197.3 MiB, up from 181.8 MiB, and Jimp's is
    1198.6 MiB.
  • The published web codec benchmark is rerun again after the JPEG XL and AVIF codecs started
    loading their heavy code on first use. All 122 supported cases still pass. Against the earlier
    November 24 run, PureJsImage median peak RSS is 14.1 MiB lower and median wall time 2.9% lower.
    Peak RSS on the photo pipeline is 180.1 MiB, 85.0% below Jimp's 1197.3 MiB, and benchmark
    startup import is 110.9 MiB in 83 ms instead of 130.2 MiB in 146 ms. auto-orient-6 and
    jpeg-to-png read 18 to 30 MiB higher than before, because of the benchmark harness swing
    described in the next entry. The run's speed check flagged nine rows, all for sharp, image-js
    and jSquash, whose versions did not change.
  • The benchmark worker decodes the measured output for validation after peak-RSS sampling stops,
    as wall timing already did, and no longer decodes the warmup output. Both decodes counted toward
    peak RSS before. They added up to 70 MiB to PNG output rows and left allocator pages resident
    in a timing-dependent way, which made some rows swing by about 30 MiB between runs. With the
    same build, PureJsImage auto-orient-6 now measures 147 to 153 MiB in six runs instead of 188
    to 220 MiB, jpeg-to-png 147 to 152 MiB instead of 202 to 238 MiB, and the photo pipeline 154
    to 160 MiB. Every engine's peak RSS drops by the cost of decoding its output. The published web
    codec snapshot is rerun with this measurement. PureJsImage peak RSS on the photo pipeline is
    153.6 MiB, 87.2% below Jimp's 1197.1 MiB, and auto-orient-6 and jpeg-to-png read 150.4
    and 150.1 MiB. Against the previous snapshot, median wall time per engine moved -8.9% to +4.8%
    at a load average of 4.3, and the speed check flagged 11 rows across all engines.
  • The benchmark result index marks a competitors run as a headline source only when it covers
    every workflow in the profile, as it already did for web codec runs. The public snapshot
    writer publishes the newest headline run. Since August 29, the one-workflow native-precision
    baseline runs counted as the newest competitors run, so benchmark:public:write failed.
  • The TIFF competitor conformance run is redone with Jimp 1.7.0 and the sharp 0.35.5 oracle.
    Every result matches the August run except one: Jimp 1.7.0's file-type 21 reads
    valid/pc260001.tif as a Sony ARW raw file and refuses to decode it, so Jimp now decodes 73 of
    the 106 comparable files instead of 74. The website TIFF comparison shows the new run.
  • The sharp benchmark engine now decodes the iPhone HEIC fixture to decide whether it can run the
    HEIC workflow. libheif 1.23.5 reads the file's metadata without an HEVC decoder, so the old
    metadata check reported a failed run instead of an unsupported one.
  • The transform-quarter-turn-jpeg benchmark passes again for PureJsImage. Its pixel samples were
    set from bilinear output one day before the default resize kernel moved to Lanczos 3, and one
    sample sat in fine texture where the two kernels differ. The two inner samples now sit in flat
    areas, use values from an independent sharp Lanczos 3 resize, and still reject a
    counter-clockwise turn. PureJsImage output is unchanged.