Pillow AVIF Plugin
Pillow AVIF Plugin is a Python library that extends Pillow's image processing capabilities by adding support for the AVIF (AV1 Image File Format) format. It provides the ability to open, manipulate, and save AVIF images using the standard Pillow API. As of its current version 1.5.5, it actively integrates with the latest Pillow releases and underlying `libavif` codecs, receiving regular updates to maintain compatibility and performance.
Warnings
- gotcha The `pillow-avif-plugin` must be explicitly imported (`import pillow_avif`) for Pillow to recognize and handle AVIF files. Simply installing the package is not enough to activate the plugin.
- breaking Compatibility with specific Pillow versions can break between plugin releases. For example, `v1.5.2` addressed compatibility issues with Pillow 11.2.1. Running an older plugin version with a much newer Pillow (or vice-versa) might lead to errors or unexpected behavior.
- gotcha Older versions of the plugin may incorrectly handle or lose image orientation metadata (EXIF `irot`/`imir`) during decoding or conversion, potentially resulting in images appearing rotated incorrectly when saved to other formats.
- gotcha Certain platform-specific issues, such as compiler errors (`incompatible-pointer-type`) or `illegal instruction segfault` on macOS ARM64, have occurred in past versions due to underlying `libavif` build processes.
Install
-
pip install pillow-avif-plugin
Imports
- Image
from PIL import Image
- pillow_avif
import pillow_avif
Quickstart
from PIL import Image
import pillow_avif # Essential to register the plugin
import os
# Create a dummy image for demonstration
img = Image.new('RGB', (100, 100), color = 'red')
# Save as AVIF
output_filename = 'example.avif'
img.save(output_filename)
print(f"Saved a red 100x100 AVIF image to {output_filename}")
# Open the AVIF image
loaded_img = Image.open(output_filename)
print(f"Loaded image format: {loaded_img.format}, size: {loaded_img.size}")
# Clean up (optional)
os.remove(output_filename)