Repository navigation
Replies: 1 comment
|
For the application-level use case, you can already load the chosen CMYK profile with from PIL import ImageCms
cmyk_profile = ImageCms.getOpenProfile("USWebCoatedSWOP.icc")
srgb_profile = ImageCms.ImageCmsProfile(ImageCms.createProfile("sRGB"))
# im is a CMYK image; cmyk_profile is the input profile chosen for it.
rgb = ImageCms.profileToProfile(
im,
cmyk_profile,
srgb_profile,
outputMode="RGB",
)
rgb.save("converted.png", icc_profile=srgb_profile.tobytes())For an untagged image, choosing that input CMYK profile is an explicit assumption by your application. If the image has an embedded profile, use that instead of silently replacing it with a fallback. Merely labelling existing CMYK values with a profile and converting those values to sRGB are also different operations; the second snippet performs a conversion. This does not decide whether Pillow should ship an Adobe profile or whether a particular redistribution license permits that. Nor does loading a different open profile make it colorimetrically equivalent to SWOP v2. The existing API lets you keep that profile-selection and deployment decision in your application. I checked this on Pillow 13.0.0 using a synthetic CMYK image and the locally installed Agfa: Swop Standard profile: loading, conversion to RGB, and embedding/reopening the sRGB output profile worked. That test was not performed with Adobe's profile and does not establish equivalence between the two. Reference: https://pillow.readthedocs.io/en/stable/reference/ImageCms.html Disclosure: AI-assisted with Codex; the API workflow above was tested locally. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The
PIL.ImageCms.createProfile(colorSpace, colorTemp=-1)function accepts colorSpace values from the ["LAB", "XYZ", "sRGB"] list.This function is very useful when dealing with RGB images that have no embedded ICC profile as it can generate the missing profile for these images in the form of the sRGB profile, as this profile seems to be the closest to what the majority of the producers around the world that don't embed the RGB profile seem to imply (there are extensive discussions on the issue, so will not repeat).
With CMYK images that have no embedded ICC profile, on the other hand, the consensus is less pronounced. However, Adobe seems to imply U.S. Web Coated (SWOP) v2 when dealing with such profile-less CMYK images.
In light of this, is there a way to add the 'SWOPv2' to the list of allowed colorSpace values which should then pull up the profile from the file (USWebCoatedSWOP.icc on Windows, for example)?
Or are there some sorts of copyright issues that would prevent PIL from doing this? If so, it would be nice to have an option for any open-source ICC profile that is closest to the Adobe one.
UPD: https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html — the profile seems to be available for redistribution as part of a 3rd party software.
All reactions