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

Add webp export option alpha_quality #7868

Closed
mzealey opened this issue Mar 11, 2024 · 3 comments · Fixed by #7872
Closed

Add webp export option alpha_quality #7868

mzealey opened this issue Mar 11, 2024 · 3 comments · Fixed by #7872

Comments

@mzealey
Copy link

mzealey commented Mar 11, 2024

cwebp has a commandline flag of -alpha_q <x>% which uses lossy-compression for the alpha channel and can significantly reduce image size, and also seems to speed up image conversion in some cases. It would be great to have this ability in Pillow also.

Additionally an option similar to -noalpha where we know the image does not contain any alpha layer saves ~27 bytes per image - not particularly significant but again a nice-to-have for cwebp compatibility.

Thanks!

@radarhere radarhere added the WebP label Mar 11, 2024
@radarhere
Copy link
Member

noalpha isn't mentioned in https://developers.google.com/speed/webp/docs/api or https://developers.google.com/speed/webp/docs/container-api, or anything similar, so I don't think this is a setting that we can use.

If you want to ensure that your Pillow image does not have transparency, that seems like just a matter of making sure the mode isn't one of "LA", "La", "PA", "RGBA" or "RGBa", making sure "transparency" isn't in the image's info, and making sure that it doesn't have a palette with an alpha channel.

@radarhere
Copy link
Member

I've created #7872 to resolve this by adding alpha_quality.

@mzealey
Copy link
Author

mzealey commented Mar 12, 2024

Oh brilliant thank you this looks great :-)

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

Successfully merging a pull request may close this issue.

2 participants