avifenc
Encode images to AVIF (AV1 Image File Format)
TLDR
Convert a specific PNG image to AVIF
Encode with a specific speed (6=default, 0=slowest and 10=fastest)
SYNOPSIS
avifenc [options] <input_file> <output_file>
PARAMETERS
Path to the source image file (e.g., PNG, JPEG, WebP).
Path for the destination AVIF file.
-q
Set the encoding quality level from 0 (lowest) to 100 (highest).
-s
Set the encoding speed from 0 (slowest, best quality) to 10 (fastest, lowest quality).
-j
Specify the number of CPU threads to use for encoding.
--min-quantizer
Set the minimum quantizer for color channels (0-63). Lower values mean higher quality.
--max-quantizer
Set the maximum quantizer for color channels (0-63). Higher values mean lower quality.
--min-quantizer-alpha
Set the minimum quantizer for the alpha channel (0-63).
--max-quantizer-alpha
Set the maximum quantizer for the alpha channel (0-63).
--depth
Set the output bit depth (8, 10, or 12 bits). 10-bit or 12-bit is suitable for HDR content.
--monochromatic
Encode the image in grayscale.
--drop-alpha
Encode without an alpha channel, even if present in the input image.
--codec
Specify the AV1 encoder to use: 'aom' (libaom), 'rav1e' (librav1e), or 'svtav1' (SVT-AV1).
--sharpness
Adjust the encoder's sharpness setting (0-7).
--tile-rows
Number of tile rows to use for parallel encoding.
--tile-columns
Number of tile columns to use for parallel encoding.
--grid
Encode a grid of images, either from multiple input files or treating a single image as a grid.
--cicp
Set color primaries, transfer characteristics, and matrix coefficients using ITU-T H.273 values.
--icc-profile
Embed an ICC color profile from the specified path.
--yuv-range
Specify YUV color range: 'limited' or 'full'.
DESCRIPTION
avifenc is a powerful command-line utility for encoding images into the AVIF (AV1 Image File Format). Based on the AV1 video codec, AVIF offers superior compression efficiency compared to older formats like JPEG and PNG, resulting in smaller file sizes with comparable or better visual quality. It supports advanced features including transparency (alpha channel), high dynamic range (HDR), wide color gamut (WCG), and various color depths (8, 10, 12-bit). avifenc can leverage different AV1 encoder implementations, such as AOM, rav1e, or SVT-AV1, allowing users to balance between output file size, visual fidelity, and encoding speed according to their needs. It's an essential tool for modern web development and image optimization.
CAVEATS
avifenc encoding can be CPU-intensive and time-consuming, especially at higher quality settings or lower speed presets. The performance can vary significantly depending on the chosen AV1 encoder (`--codec` option). Support for various input image formats depends on how libavif was compiled and which image libraries (like libjpeg, libpng, libwebp) it was linked against. While AVIF offers excellent compression, its adoption might still be limited in some older software or platforms compared to more established formats like JPEG or PNG.
KEY AVIF FEATURES
AVIF boasts several advanced features, making it a compelling choice for modern image needs. These include robust support for HDR (High Dynamic Range) and WCG (Wide Color Gamut), flexible color depths (8, 10, or 12-bit), native transparency (alpha channel), and the ability to handle image sequences (for animations or multi-layer images) and image grids. These capabilities position AVIF as a versatile and future-proof image format for a wide range of applications.
ENCODER BACKENDS
avifenc can utilize different AV1 encoder implementations, each with distinct characteristics:
aom: The reference encoder, generally offers excellent quality but can be slower for encoding.
rav1e: A Rust-based encoder known for a good balance between speed and quality, often faster than aom at similar quality levels.
svtav1: An Intel-developed encoder highly optimized for speed, often providing the fastest encodes, particularly on supported hardware.
HISTORY
The AVIF format was standardized in 2019 by the Alliance for Open Media (AOMedia), building upon the open and royalty-free AV1 video codec. avifenc is a core component of libavif, an open-source library that provides comprehensive AVIF encoding and decoding capabilities. Development of libavif and consequently avifenc began shortly after the AVIF specification's release, with continuous improvements in performance, feature support, and encoder integrations as the AV1 ecosystem matures. Its usage has grown steadily with increasing browser and application support for AVIF images.