Repository navigation
v2.0.0
2.0.0
This release replaces sharp with @napi-rs/image for all image work and adds AVIF as an output format. Some image options had no equivalent in the new library, so this is a major release. See Breaking changes and Migrating from 1.x below.
New
- AVIF output.
convertImageBuffer,convertArchiveImages, andconvertArchiveaccept'avif'as a format. The newoptions.avifgroup supports:quality(0 to 100, default90;100is lossless)alphaQuality(defaults toquality)speed(1 to 10, default4)chromaSubsampling('4:4:4'by default to keep colored line art sharp;'4:2:0'gives smaller files)threads(encoder threads per image, default0for every core; pass1when converting several images at once withconcurrency)
- AVIF pages are recognized as images.
avifis now inIMAGE_EXTENSIONS, so AVIF pages work with image info, perceptual hashing, renaming, and later conversions. - The benchmark includes AVIF.
BENCHMARK_IMAGE_FORMATSis nowwebp,avif,png,jpg, so a defaultbenchmarkArchiverun produces 16 archives instead of 12. Useoptions.imageFormats(or--image-formats=inbenchmark.js) to pick a subset.
Breaking changes
sharpis no longer a dependency. Image decoding and encoding now use@napi-rs/image.setImageConcurrencyhas been removed. It set libvips threads per image, and the new library has no equivalent setting. Images still run on libuv's threadpool (4 threads by default), so raiseUV_THREADPOOL_SIZEto convert more than 4 images at once.WebpOptions.effortandWebpOptions.smartSubsamplehave been removed. WebP encoding now takes onlyquality(default92).- Perceptual hashes have changed.
computeImagePHashandcomputeArchiveImagePHashnow resize and convert to grayscale with a different library, so their values will not exactly match hashes from 1.x. Recompute any stored hashes before comparing them against new ones. - PNG
compressionLevelmaps to three levels. It still accepts0to9, but0to3is fast,4to6, and7to9is best. The default is 8. - PNG palette quality works differently. With
palette: true,qualityis now the maximum quality for palette quantization (default100). File sizes for the same setting will differ from 1.x.
Fixes
- pHash handles images with transparency. Pages with an alpha channel, 16-bit pages, and floating-point pages are now read correctly.
Migrating from 1.x
- Remove calls to
setImageConcurrency. To run more than 4 images at once, setUV_THREADPOOL_SIZEbefore the process first uses the threadpool. - Remove
effortandsmartSubsamplefrom anywebpoptions. TypeScript will flag them. - If you store perceptual hashes, recompute them with 2.0.0.