What is the avifenc Command-Line Utility
This article explains the purpose, key features, and practical use of
the avifenc command-line utility, a core tool provided with
the open-source libavif library. You will learn how this
tool converts traditional image formats into highly compressed AVIF
files and how to use its basic commands for web optimization.
The Purpose of avifenc
The primary purpose of the avifenc command-line utility
is to encode raster images into the AV1 Image File Format (AVIF). AVIF
is a modern, next-generation image format based on the AV1 video
compression standard. It offers significantly better compression than
older formats like JPEG, PNG, and even WebP, allowing developers and
system administrators to drastically reduce image file sizes without
sacrificing visual quality.
Because libavif is the de facto reference library for
writing and reading AVIF files, avifenc serves as the
standard tool for generating these files directly from the terminal or
within automated server scripts.
Key Features and Capabilities
The avifenc utility provides a wide range of
configuration options to customize how images are compressed and
formatted.
- Format Conversion: It accepts input files in
various formats—including PNG, JPEG, and raw YUV/RGB—and outputs a
standardized
.aviffile. - Lossy and Lossless Compression: Users can choose to perform highly efficient lossy compression or preserve exact pixel data using lossless mode.
- Advanced Color Support:
avifencsupports high dynamic range (HDR) and wide color gamut (WCG) images, with color depths of 8, 10, or 12 bits per channel. - Chroma Subsampling Control: It allows control over chroma subsampling configurations (such as 4:4:4, 4:2:2, and 4:2:0) to balance color detail against file size.
- Speed and Quality Tuning: Users can adjust encoding speed settings to trade processing time for better compression efficiency.
Basic Usage Examples
Using avifenc is straightforward. In its simplest form,
the command requires only an input file and a designated output file
name:
avifenc input.png output.avifTo control the quality of the compression, you can use the minimum and maximum quality flags (ranging from 0 to 63, where 63 is the highest quality/lossless):
avifenc --min 0 --max 63 input.jpg output.avifFor faster encoding at the expense of a slightly larger file size, you can adjust the speed parameter (ranging from 0 to 10, where 10 is the fastest):
avifenc --speed 8 input.png output.avifBy integrating avifenc into build pipelines and web
servers, developers can automate the creation of lightweight,
fast-loading images that improve website performance and reduce
bandwidth consumption.