How to Convert AVIF to PNG Using avifdec
This article provides a straightforward guide on how to convert AVIF
images to PNG format using the avifdec command-line utility
from the libavif library. It covers the essential
installation steps, the basic conversion command, and advanced options
for managing color depth and performance.
What is avifdec?
avifdec is a command-line companion tool included with
libavif, the open-source library for encoding and decoding
AVIF (AV1 Image File Format) files. It allows you to quickly decode AVIF
images and save them into widely compatible formats like PNG or
JPEG.
Installing libavif
Before using avifdec, you need to install the package
containing the libavif binaries on your system.
macOS (via Homebrew):
brew install libavifUbuntu/Debian:
sudo apt update sudo apt install libavif-binFedora:
sudo dnf install libavif-tools
Basic Conversion Command
Once installed, converting an AVIF file to a PNG is highly straightforward. Use the following command syntax in your terminal:
avifdec input.avif output.pngReplace input.avif with the path to your source AVIF
file and output.png with your desired destination file
name. The utility automatically detects the .png extension
and outputs the image in PNG format.
Advanced avifdec Options
You can customize the decoding process using several command-line flags:
Adjusting Bit Depth
By default, avifdec outputs the image at its native
depth. You can manually set the output bit depth (e.g., 8 or 16 bits per
channel) using the -d or --depth flag:
avifdec --depth 8 input.avif output.pngMulti-threaded Decoding
To speed up the conversion process, especially for large images, you
can specify the number of CPU threads to use with the -j or
--jobs flag:
avifdec --jobs 4 input.avif output.pngIgnoring Color Profiles
If you want to ignore the embedded ICC profile during the decoding
process, use the --ignore-icc flag:
avifdec --ignore-icc input.avif output.png