Repository navigation
Use ICC profile from info dictionary when saving WebP - #10678
Yasser-Ameur wants to merge 1 commit into
Conversation
When no icc_profile argument is passed, the profile is now taken from the image's info dictionary, as PNG, TIFF and AVIF do. This is only done for modes that are saved without a colour conversion (RGB, RGBA, RGBX, P and PA), so a grayscale or CMYK profile is never written next to RGB pixels. icc_profile=None still writes no profile.
|
Hi. Just for our awareness, are you using AI to create these PRs? |
This makes me think that we should be dropping the icc_profile on conversion? >>> from PIL import Image
>>> im = Image.new("L", (1, 1))
>>> im.info["icc_profile"] = "test"
>>> im.convert("RGB").info
{'icc_profile': 'test'}Would you be interested in opening a new PR for that? |
I would imagine they are, as python-babel/babel#1524 on Babel (which I maintain) looks very AI :) (Just happened to spot the same username over there...) |
|
Yes, these are AI assisted, reviewed and tested by me. Each one is reproduced on the released version and run against a new test before it is sent. The same goes for the Babel PR. If you'd prefer fewer of these, or a different form, tell me and I'll follow that. |
|
Yes, I'll open a separate PR that drops |
Changes proposed in this pull request:
icc_profileis passed. A JPEG with an embedded profile keeps it when it is saved as PNG, TIFF or AVIF, and loses it as WebP, so a wide gamut image is shown with the wrong colours after the conversion._saveand_save_allnow fall back toim.info.get("icc_profile")when noicc_profileargument is given, as the PNG, TIFF and AVIF plugins do.icc_profileargument behaves as before, andicc_profile=Nonestill saves without a profile.Tests/test_file_webp_metadata.pycover a still and an animated save, and a grayscale image whose profile must not be written. A release note is added todocs/releasenotes/13.1.0.rst.On 13.0.0 this prints 3144 for the source, PNG and TIFF, and 0 for WEBP.