Repository navigation
Remove ICC profile from info when convert() changes the color space - #10683
Open
Yasser-Ameur wants to merge 2 commits into
Open
Yasser-Ameur wants to merge 2 commits into
Yasser-Ameur wants to merge 2 commits into
Conversation
A grayscale or CMYK profile does not describe RGB pixels, but convert() copied it to the new image, and the PNG, TIFF and AVIF writers then embedded it. The profile is still kept for conversions within a color space, such as RGB to RGBA or P, and the profile ImageCms sets for LAB conversions is left alone. ImageEnhance.Color converts to L and back to build its degenerate image, and remap_palette converts a P image to L as an index trick. Both now keep the profile of the source image.
Yasser-Ameur
marked this pull request as ready for review
December 1, 2026 13:17
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
Image.convert()no longer copiesinfo["icc_profile"]to the new image when the conversion changes the color space, for example from L or CMYK to RGB. A grayscale or CMYK profile does not describe RGB pixels, and the PNG, TIFF and AVIF writers embedinfo["icc_profile"]when saving. ImageCms.profileToProfile error #6666 is the user-facing case: the profile of a converted image was passed toprofileToProfileand failed to build a transform.resize(),reduce()andtransform()convert RGBA to RGBa and back throughconvert(), so dropping the profile on any mode change would strip it from every RGBA resize. The same applies to RGB to RGBA before pasting or saving PNG.ImageEnhance.Color(the degenerate image it blends from) andremap_palette(which converts P to L as an index trick, and now calls the conversion body directly).infois not modified.Suggested by @radarhere in #10678.
Checked against the 13.0.0 release with the same change applied to its Python files: the eight new removal tests fail without it and pass with it, no other result changes in
test_image.py,test_image_convert.py,test_imageenhance.py,test_imageops.py,test_file_gif.py,test_file_png.pyandtest_file_jpeg.py, and the bytes of an optimised GIF save are identical. The full suite on main is left to CI.