AV1 Image File Format specifies a file format for storing images or sequences of images that have been compressed with AV1 in HEIF containers
With AVIF, you can reduce the size of lossy images considerably compared with JPEG or even Google's WebP format.
Compared to JPEG as a baseline, Daniel Aleksandersen found a median reduction of 50.3% in file size, compared to WebP's 31.5% reduction.
In comparing a photograph of an F1 car, Jake Archibald found that WebP was 57.7% of the size, and AVIF was an impressive 18.2%.
You can use an ecosystem of libraries in Node.js to process images. This article focuses on the sharp module.
Sharp is a Node.js image processing library that can process images in various formats, including JPEG, PNG, WebP, and SVG.
A typical use of this high-speed Node.js module is to convert large images in popular formats into smaller, web-friendly JPEG, PNG, WebP, GIF, and AVIF images of varying sizes.
sharp is a Node.js module that provides high-performance image processing. This module assists with UGC management by providing an easy solution for reading, enhancing, and saving image files. Sharp compresses images more quickly and produces better results than most Node.js modules, such as ImageMagick, Jimp, and Squoosh.
Due to utilizing libvips, resizing an image is 4x-5x faster than using the fastest ImageMagick and GraphicsMagick settings.
The system holds small portions of uncompressed image data in memory. It processes them simultaneously, taking full advantage of multiple CPU cores and L1/L2/L3 cache.
Color spaces, embedded ICC profiles, and alpha transparency channels are correctly handled. The Lanczos resampling ensures that quality is not sacrificed for speed.
In addition to image resizing, the application offers rotation, extraction, compositing, and gamma correction operations.
You can find complete installation instructions, API documentation, benchmark tests, and a changelog at sharp.pixelplumbing.com. If you're looking for tutorials on using sharp, you can check out their FAQ section or this tutorial on LogRocket.
In July 2020, Sharp added support for AVIF.
Although AVIF images smaller than 16x16 pixels can be created, most web browsers can't display them correctly. It isn't possible to create AVIF image sequences.
The following options are available:
- Quality: Change quality, integer from 1-100
- Lossless: Use lossless compression, boolean
- Effort: CPU effort, integer between 0 (fastest) and 9 (slowest)
- ChromaSubsampling: Set custom subsampling, string input