AVIF Local Support adds modern AVIF image support to WordPress while keeping compatibility with existing JPEG media. Built by a Boston photographer who just wanted their website to look as good as possible.
GitHub Repository: https://github.com/ddegner/avif-local-support
- Local-first: all processing happens on your own server (works great on local environments like Local, MAMP, Docker) — no external calls.
- Image quality first: uses Imagick when available for high-quality resizing (LANCZOS), corrects EXIF orientation, and preserves ICC color profiles and EXIF/XMP/IPTC metadata when possible.
-
Tunable quality and speed: set AVIF quality (0–100) and encoder speed (0–10) to balance fidelity and performance.
-
Wraps existing
tags inwith an AVIFwhen an.avifversion is present. - Converts JPEG originals and generated sizes to AVIF on upload, or via a daily/background scan.
- Preserves EXIF/XMP/IPTC metadata and ICC color profiles by default (when using ImageMagick/Imagick).
- WordPress-aware resizing logic enabled by default to avoid double-resizing when generating AVIF sizes from originals.
- New encoder controls: choose chroma subsampling (4:2:0, 4:2:2, 4:4:4) and bit depth (8/10/12-bit). Defaults: 4:2:0 and 8-bit.
- Tools include: convert missing AVIFs, upload a test JPEG, and delete all AVIF files in uploads.
How it works
- Front end: Filters common image outputs to add an AVIF
ahead of the original JPEG. Browsers that support AVIF will use it; others fall back to JPEG. - Conversion: Uses Imagick when available (preferred) — with auto-orientation and LANCZOS resizing — or GD with an AVIF encoder. Quality, speed, chroma subsampling, and bit depth are configurable (subsampling/bit depth applied via Imagick when supported).
- Scheduling: Optional daily scan to backfill missing
.aviffiles for existing JPEGs.
Requirements
- PHP 8.0 or later (8.1+ recommended)
- WordPress 6.5 or later
- Imagick PHP extension recommended for best quality and metadata/ICC preservation. GD fallback supported.
Ubuntu/Debian setup (summary)
For local JPEGAVIF conversion you need either Imagick with AVIF-enabled ImageMagick, or GD with AVIF support:
-
Imagick path (recommended)
- PHP extension: imagick
- System libraries: ImageMagick built with HEIF/AVIF support (via libheif)
- Notes: This path enables higher-quality resizing and preserves metadata/ICC profiles
-
GD path (fallback)
- PHP extension: gd built with AVIF support (provides
imageavifon PHP 8.1+) - Notes: Ensure your distro』s PHP GD is compiled with AVIF; some builds omit it
- PHP extension: gd built with AVIF support (provides
-
Helpful extras
- PHP exif extension (for orientation handling in the GD fallback)
- Web server configured to serve
.avifasimage/avif(Apache/Nginx/LiteSpeed)
Official documentation:
– PHP Imagick installation: https://www.php.net/imagick
– PHP GD installation (AVIF details): https://www.php.net/manual/en/image.installation.php
– ImageMagick format support (AVIF/HEIF): https://imagemagick.org/script/formats.php
– Apache MIME configuration: https://httpd.apache.org/docs/current/mod/mod_mime.html
– Nginx MIME configuration: https://nginx.org/en/docs/http/ngx_http_types_module.html






