Pillow AVIF Plugin

1.5.5 · active · verified Thu Apr 09

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

Install

Imports

Quickstart

This quickstart demonstrates how to save and load an AVIF image using Pillow after ensuring the `pillow_avif` plugin is imported, which registers the AVIF format handler with Pillow. Without `import pillow_avif`, `Image.open()` and `Image.save()` will not support AVIF files.

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)

view raw JSON →