diff --git a/nodes.py b/nodes.py index 99dc07227..93988ba50 100644 --- a/nodes.py +++ b/nodes.py @@ -1702,6 +1702,25 @@ class LoadImage: return (components.images, 1.0 - components.alpha[..., -1] if components.alpha is not None else torch.zeros((components.images.shape[0], 64, 64), dtype=torch.float32, device="cpu")) img = node_helpers.pillow(Image.open, image_path) + import io + from PIL import ImageCms + + try: + if "icc_profile" in img.info: + icc_bytes = img.info["icc_profile"] + + src_profile = ImageCms.ImageCmsProfile(io.BytesIO(icc_bytes)) + dst_profile = ImageCms.createProfile("sRGB") + + img = ImageCms.profileToProfile( + img, + src_profile, + dst_profile, + outputMode="RGB" + ) + except Exception as e: + print("Icc color profile conversion failed:",e) + output_images = [] output_masks = []