Fix: Apply embedded ICC color profiles when loading images to ensure correct sRGB conversion#11241
Fix: Apply embedded ICC color profiles when loading images to ensure correct sRGB conversion#11241Vijay2359 wants to merge 2 commits intoComfy-Org:masterfrom
Conversation
|
#Benefits Eliminates color shifts when loading P3 / AdobeRGB / ProPhoto images Matches behavior of color-managed applications (Photoshop, macOS Preview, Chrome, etc.) No breaking changes for sRGB workflows Very low overhead; only runs if an ICC profile exists |
Test Evidence CheckIf this PR modifies behavior that requires testing, a test explanation is required. PRs lacking applicable test explanations may not be reviewed until added. Please add test explanations to ensure code quality and prevent regressions. If this PR changes user-facing behavior, visual proof (screen recording or screenshot) is required. PRs without applicable visual documentation may not be reviewed until provided. You can add it by:
|
Summary
This PR adds proper ICC color profile handling to the
LoadImagenode so that non-sRGB images (such as Display-P3, AdobeRGB, ProPhotoRGB, Rec.2020, etc.) are correctly converted to sRGB during loading.This fixes the color-shift problem reported in:
Fixes #11101
Problem
ComfyUI currently ignores embedded ICC profiles, which causes images in wide-gamut color spaces to appear washed-out or desaturated because they are interpreted as sRGB without conversion.
Solution
This PR:
icc_profilefield)ImageCms.profileToProfile()Example Patch
import io
from PIL import ImageCms