sd-scripts icon indicating copy to clipboard operation
sd-scripts copied to clipboard

Color profiles of are not handled by the scripts

Open Hirmuolio opened this issue 4 months ago • 0 comments

The script treats all images as sRGB even if they have color profiles.

Handling of color profiles needs to be added in image loading.

https://github.com/kohya-ss/sd-scripts/blob/2857f21abf6ed53abe89dd512b3bf25fd2913e03/library/train_util.py#L2490

Something like this:

image = Image.open( path )
icc = image.info.get('icc_profile', '') # Get color profile in the image
if icc:
    src_profile = ImageCms.ImageCmsProfile( io.BytesIO(icc) )
    srgb_profile = ImageCms.createProfile("sRGB")
    image = ImageCms.profileToProfile(image, src_profile, srgb_profile) # Convert image to sRGB

Hirmuolio avatar Aug 17 '25 16:08 Hirmuolio