Sub topic 7
Embedding, assigning and converting
This chapter assumes you know what an ICC profile is and what a working space is (covered earlier in this tutorial). It also assumes you have used the Edit menu of an image editor such as Photoshop or Affinity. Embedding, assigning and converting are three operations that sound alike. Mixing them up is one of the most common causes of colour shifts between screen and print.
Three operations, three different effects
A pixel stores numbers, such as R=200, G=120, B=60. The numbers only mean a colour once a profile says which colour space they belong to. Each operation acts on the numbers, the profile, or both.
| Operation | Changes pixel numbers? | Changes the profile? | Changes how the image looks? |
|---|---|---|---|
| Embed | No | Writes the current profile into the file | No |
| Assign | No | Replaces the profile the editor thinks the numbers belong to | Yes, because the same numbers are now read as a different colour |
| Convert | Yes | Replaces the profile and recalculates the numbers | No, apart from unavoidable gamut clipping |
The practical rule is that assign changes the appearance and keeps the numbers. Convert keeps the appearance as far as possible and changes the numbers.
Embedding
Embedding stores a copy of a profile inside the image file, so any application that opens it can interpret the numbers correctly. JPEG, TIFF, PNG, PSD and PDF can all carry an embedded profile.
Embedding does nothing to the pixels. It only labels them. An embedded profile is a statement of fact about the file: "these numbers are in Adobe RGB." If the statement is wrong, the file will display wrongly everywhere.
You can inspect the embedded profile from the command line:
exiftool -ICC_Profile:ProfileDescription -ICC_Profile:ProfileClass -ICC_Profile:ColorSpaceData photo.jpgIf the command prints nothing, the file is untagged.
Assigning
Assigning tells the application which profile describes the existing numbers. It is the right tool in one situation: the file is untagged or wrongly tagged, and you know what the numbers really mean.
For example, a scan arrives with no profile, and the scanner's documentation says it outputs sRGB. Assigning sRGB makes the editor interpret the numbers correctly. The numbers stay the same and the colour on screen may change, because the editor now has a different idea of what they mean.
Assigning is a correction of a label. Do not use it to "try a different look". If you assign a profile that is wrong, you produce a wrong image and nothing warns you.
This Pillow snippet shows an assign. It creates a pixel-for-pixel copy and writes a different profile tag. It reads the pixels but never transforms them:
from PIL import Image, ImageCms
im = Image.open("scan_untagged.png").convert("RGB")
srgb = ImageCms.createProfile("sRGB")
tag = ImageCms.ImageCmsProfile(srgb).tobytes()
# Assign: same pixel values, new label.
im.save("scan_tagged.png", icc_profile=tag)Converting
Converting recalculates the numbers so that the colour stays as close as possible when the colour space changes. The colour management module (CMM) takes the source numbers, maps them to the profile connection space using the source profile, and then maps them to the destination space using the destination profile. The rendering intent and black point compensation settings control how colours outside the destination gamut are handled.
Because the destination gamut is usually smaller than the source gamut, conversion can lose information. Saturated colours may be clipped or compressed. Converting back does not restore them.
import io
from PIL import Image, ImageCms
im = Image.open("photo.jpg")
src = ImageCms.ImageCmsProfile(io.BytesIO(im.info["icc_profile"]))
dst = ImageCms.getOpenProfile("press_profile.icc")
out = ImageCms.profileToProfile(
im,
src,
dst,
renderingIntent=ImageCms.Intent.RELATIVE_COLORIMETRIC,
outputMode="CMYK",
flags=ImageCms.Flags.BLACKPOINTCOMPENSATION,
)
out.save("photo_cmyk.tif", icc_profile=dst.tobytes())This script assumes photo.jpg has an embedded profile. If it does not, im.info["icc_profile"] raises a KeyError. That error is useful, because it stops you from converting from a guessed source. In a real pipeline, handle untagged files explicitly, using an assign step with a known profile.
The last line matters. The converted numbers are only meaningful with dst, so the file must be saved with dst embedded. A CMYK file without a profile has no reliable meaning.
What happens when you open a file
Most editors compare the embedded profile with your working space and apply a colour management policy. The usual choices are:
- Preserve embedded profiles. The document keeps its own profile and is displayed correctly. This is the safest default for files you receive.
- Convert to the working space. The numbers change so the file matches your working space. This is common for photographers who standardise on one RGB space.
- Ignore the profile and use the working space. This amounts to an assign and usually changes the appearance. Choose it only when you know the tag is wrong.
If the file has no profile, the editor typically asks you to assign one. Choose the profile of the device or workflow that produced the file. If you cannot find out, sRGB is the most common assumption for web-sourced images. Treat it as a guess and note it.
Choosing the right operation
The decision flow below covers most day-to-day cases.
Two points follow from the flow:
- Assign only to fix a missing or wrong label, and do it before any conversion.
- Every save should embed the profile that matches the numbers, unless a specific workflow forbids it.
Common errors
- Assigning when you meant to convert. You change RGB values to CMYK-looking colours on screen, but the file is still RGB and the numbers do not match the press. Check the colour mode and the profile name in the document info bar.
- Converting from a wrong source. If an Adobe RGB file was mislabelled sRGB, converting from sRGB produces dull colour that cannot be fixed afterwards. Fix the label first, with assign, and then convert.
- Converting twice. Going RGB to CMYK to another CMYK condition accumulates clipping and can change black generation. Keep an RGB master, and convert from that master for each output.
- Discarding the profile on export. Some "save for web" settings strip embedded profiles. Convert to sRGB first, then embed it.
- Embedding a profile that was not used. Embedding does not convert. Embedding a press profile in an RGB file labels it incorrectly.
Exercise
A client sends a JPEG with no embedded profile. You know it came from a camera set to Adobe RGB. You need a CMYK file for a coated press. List the steps in order and say which operation each one is.
Show answer
1. Assign Adobe RGB to the file. This is an assign, because the numbers are already Adobe RGB and only the label is missing. 2. Convert from Adobe RGB to the press CMYK profile, choosing a rendering intent (typically relative colorimetric with black point compensation). This is a convert, because the numbers must be recalculated for the press gamut. 3. Save with the press profile embedded. This is an embed, because the new numbers are only meaningful with that profile. Converting before assigning would use a wrong source, and skipping the final embed would leave the CMYK numbers without a reliable meaning.