Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVIF output is always saved in RGB even input is L #325

Open
MimoKar opened this issue Jan 11, 2025 · 4 comments
Open

AVIF output is always saved in RGB even input is L #325

MimoKar opened this issue Jan 11, 2025 · 4 comments

Comments

@MimoKar
Copy link

MimoKar commented Jan 11, 2025

Describe the bug

When creating AVIF in L mode, it is always saved in RGB. the mode parameter in save function is not working - when added to force mode the image is not saved.

Steps/Code to Reproduce

Try to save some image which is in L mode.

Expected Results

Image is saved in L mode

Actual Results

no image saved

Versions

3.13.1 (tags/v3.13.1:0671451, Dec  3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)]
Windows-11-10.0.27768-SP0
0.21.0
{'libheif': '1.19.5', 'HEIF': 'x265 HEVC encoder (3.5+1-f0c1022b6)', 'AVIF': 'AOMedia Project AV1 Encoder v3.11.0', 'encoders': {'x265': 'x265 HEVC encoder (3.5+1-f0c1022b6)', 'aom': 'AOMedia Project AV1 Encoder v3.11.0', 'mask': 'mask'}, 'decoders': {'libde265': 'libde265 HEVC decoder, version 1.0.15', 'aom': 'AOMedia Project AV1 Decoder v3.11.0'}}
@bigcat88
Copy link
Owner

from PIL import Image
import pillow_heif

pillow_heif.register_avif_opener()

a = Image.open("../tests/images/non_heif/L_8__128x128.png")
a.save("test.avif")

b = Image.open("test.avif")
print(b.mode)
b.save("test2.avif")

c = Image.open("test2.avif")
print(c.mode)

Output:

L
L

Can you post the minimal reproducible code so I can see what the problem is?

@MimoKar
Copy link
Author

MimoKar commented Jan 12, 2025

Hi,

yes it is showing in my case same result. So then the result colorspace is expanded from 8-bit to 24-bit in avif files?
is there a way to force it to be 8-bit in avif (pure grayscale)?

image image

@bigcat88
Copy link
Owner

Can you share your code and the input file you are testing it on because in my tests everything is working fine.

L mode is a grayscale image

@MimoKar
Copy link
Author

MimoKar commented Jan 12, 2025

i am not sure now how to correctly check the bits per pixel value in windows. i feel that irfanview is getting innacurate.
even the hief-enc is producing 24bpp images as per irfanview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants