Skip to content

Support monochrome AVIF saving and loading #9465

@NogginBops

Description

@NogginBops

What did you do?

I have a bunch of gray-scale datasets what I would like to compress using the AVIF format to reduce the amount of data sent. Currently I'm able to store my grayscale data in an RGB AVIF file, but I want to use the grayscale compression ability of AVIF to hopefully get an even better compression ratio and not have to discard a bunch of extra data when loading the data file.

What did you expect to happen?

For the AVIF encoder/decoder to support gray-scale images.

What actually happened?

The AVIF encoder/decoder only supports RGB images.

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.12.10
  • Pillow: 12.1.1
im = PIL.Image.fromarray(img_data.astype(np.uint8)) # shape (nx, ny, 1)
im.save("image.avif")
# This saves an RGB avif file instead of a grayscale file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions