Pillow JPEG-XL Plugin

1.3.7 · active · verified Fri Apr 17

Pillow plugin for adding JPEG-XL (JXL) image format support, leveraging Rust bindings for performance. It seamlessly integrates with Pillow's `Image.open()` and `Image.save()` methods. The library is actively maintained with frequent minor releases, often addressing CI improvements, dependency updates, and adding new JXL features like float16 decode and EXIF support.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to open and save JPEG-XL images using the standard Pillow API. The `pillow-jxl-plugin` integrates directly, so no special JXL-specific functions are called; simply use `Image.open()` and `Image.save()` with `.jxl` file extensions.

from PIL import Image
import os

# Note: pillow-jxl-plugin automatically registers itself upon installation.
# No explicit 'import pillow_jxl' is usually needed.

# Create a dummy image for saving
try:
    dummy_img = Image.new('RGB', (100, 100), color = 'red')
    dummy_img.save('example.jxl', lossless=True, speed=4)
    print("example.jxl created successfully.")

    # Open a JPEG-XL image
    img = Image.open('example.jxl')
    print(f"Opened JXL image: {img.format}, mode={img.mode}, size={img.size}")

    # Convert to another format and save (optional)
    img.convert('RGB').save('example.png')
    print("example.png saved.")

    # Clean up (optional)
    os.remove('example.jxl')
    os.remove('example.png')
    print("Cleaned up example files.")

except FileNotFoundError:
    print("Make sure 'example.jxl' (or another JXL file) exists in the current directory if you want to test opening a pre-existing one.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →