HomeGuidesHow to Convert Images to AVIF
Guide

How to Convert Images to AVIF

3 methods — PixelForge, ImageMagick CLI, and Python

AVIF is the most efficient image format for the web — delivering 30–50% smaller files than JPEG and 20–30% smaller than WebP at the same visual quality. All major browsers now support it, and Google's Core Web Vitals tooling actively rewards smaller image payloads. Here are three ways to convert your image library to AVIF in bulk.

Method 1: Using PixelForge (fastest, no software needed)

Convert hundreds of images to AVIF in your browser — no CLI or dependencies required.

  1. 1Go to the Convert Images to AVIF tool on PixelForge.
  2. 2Upload your images or a ZIP of images.
  3. 3PixelForge automatically sets AVIF as the output format.
  4. 4Click Process and download the converted AVIF files as a ZIP.

AVIF encoding is more CPU-intensive than JPEG or WebP, so large batches may take slightly longer. PixelForge processes everything server-side — your machine is not affected.

Method 2: Using ImageMagick (command line)

ImageMagick is a free, cross-platform CLI tool with full AVIF support. Best for scripting or CI pipelines.

  1. 1Install ImageMagick: brew install imagemagick (macOS) or apt install imagemagick (Ubuntu).
  2. 2Verify AVIF support: magick identify -list format | grep AVIF
  3. 3Convert a single image: magick input.jpg -quality 80 output.avif
  4. 4To convert an entire folder, run the loop below.

bash

# Convert all JPEGs in a folder to AVIF
mkdir -p ./avif-output

for f in ./images/*.jpg ./images/*.jpeg ./images/*.png ./images/*.webp; do
  [ -f "$f" ] || continue
  base=$(basename "${f%.*}")
  magick "$f" -quality 80 "./avif-output/${base}.avif"
  echo "Converted $f → ${base}.avif"
done

# Compare file sizes
du -sh ./images ./avif-output

Quality 75–85 is the sweet spot for AVIF web images. Lower than 70 introduces visible artifacts in smooth gradients; higher than 85 produces files comparable in size to WebP.

Method 3: Using Python (Pillow)

Programmatic AVIF conversion — best for automated pipelines, dynamic image processing, or large-scale batches.

  1. 1Install Pillow 9.1+: pip install --upgrade Pillow
  2. 2On macOS, install libavif first: brew install libavif, then reinstall Pillow.
  3. 3Run the script below, adjusting paths and quality as needed.

python

from PIL import Image
import os

input_dir = "./images"
output_dir = "./avif-output"
QUALITY = 80  # 60–85 recommended for web

os.makedirs(output_dir, exist_ok=True)

for filename in os.listdir(input_dir):
    if filename.lower().endswith((".jpg", ".jpeg", ".png", ".webp")):
        img = Image.open(os.path.join(input_dir, filename))

        # AVIF supports RGB and RGBA — convert to appropriate mode
        if img.mode in ("RGBA", "LA", "P"):
            img = img.convert("RGBA")
        else:
            img = img.convert("RGB")

        out_name = os.path.splitext(filename)[0] + ".avif"
        img.save(os.path.join(output_dir, out_name), "AVIF", quality=QUALITY)
        print(f"Converted {filename} → {out_name}")

print("Done!")

Pillow's AVIF support requires libavif to be installed on the system. If you see 'encoder avif not available', install libavif and rebuild Pillow with pip install --no-binary Pillow Pillow.

Frequently asked questions

What is AVIF and why should I use it?

AVIF (AV1 Image File Format) is a modern image format derived from the AV1 video codec. It delivers significantly smaller file sizes than JPEG (30–50% smaller) and WebP (20–30% smaller) at the same perceptual quality. Smaller images load faster, improve Core Web Vitals scores, and reduce bandwidth costs.

What browsers support AVIF?

AVIF is supported in Chrome (85+), Firefox (93+), Safari (16+), and Edge (121+). It covers over 93% of global browser usage as of 2025. For the remaining users, serve AVIF inside a <picture> element with a WebP or JPEG fallback.

How does AVIF compare to WebP?

AVIF produces smaller files than WebP at equivalent quality, especially for photos and images with smooth gradients. WebP encoding is significantly faster. For most web projects, AVIF is the better long-term choice; use WebP as a fallback for older Safari and browser versions.

Can I convert AVIF back to JPEG or PNG?

Yes — PixelForge accepts AVIF as input. Use the Bulk Image Convert tool, upload your AVIF files, and select JPEG or PNG as the output format.

Ready to try the fastest method?

Convert JPG, PNG, and WebP images to AVIF format in bulk. The most efficient modern image format for the web.

Convert to AVIF — free