--
published: true
description: "A 24 × 24 icon shows why stripping an ICC profile and converting to sRGB produce different results."

tags: png, python, webdev, design

A green pixel in a 24 × 24 PNG still read (96, 160, 112) after I removed its ICC profile. When I converted the original pixel to sRGB with Pillow, it read (39, 161, 110). Its alpha stayed the same.

If a viewer treats the untagged PNG as sRGB, the two outputs show different greens. The first file kept the original numbers. The second changed those numbers to represent the original color in sRGB.

One pixel, two exports

I started with a PNG tagged with an Adobe RGB–compatible ICC profile and used the same green pixel for both operations.

PNG Stored RGB at the sampled pixel Color information
Original (96, 160, 112) Adobe RGB–compatible ICC profile
Profile stripped (96, 160, 112) Untagged in this test
Converted to sRGB (39, 161, 110) sRGB ICC profile

The red channel fell from 96 to 39 during conversion. That difference is easy to spot when both outputs are shown as sRGB. To compare the converted file with the original, though, the viewer needs to honor the original ICC profile. In that comparison, different RGB numbers are how the conversion aims to preserve appearance, within the limits of the target color space.

The illustration below shows the two measured greens side by side in sRGB.

Try it with Pillow

Use a PNG with an embedded RGB ICC profile. For a visible comparison, start with a profile other than sRGB and pick a fully opaque colored pixel. Pass its zero-based x and y coordinates to the script. It writes both outputs, reopens them, and reads the same pixel from each saved file.

# Usage: python compare_png_profiles.py icon.png 12 12 import io import sys from pathlib import Path from PIL import Image, ImageCms source_path = Path(sys.argv[1]) point = (int(sys.argv[2]), int(sys.argv[3])) with Image.open(source_path) as source: icc = source.info.get("icc_profile") if not icc: raise SystemExit("Use a PNG with an embedded RGB ICC profile.") rgba = source.convert("RGBA") # Build a fresh image from pixel bytes so source metadata isn't copied. untagged = Image.frombytes("RGBA", rgba.size, rgba.tobytes()) untagged.save("icon-untagged.png") source_profile = ImageCms.ImageCmsProfile(io.BytesIO(icc)) srgb = ImageCms.ImageCmsProfile(ImageCms.createProfile("sRGB")) converted = ImageCms.profileToProfile( rgba.convert("RGB"), source_profile, srgb, outputMode="RGB" ) converted.putalpha(rgba.getchannel("A")) converted.save("icon-srgb.png", icc_profile=srgb.tobytes()) for path in (source_path, Path("icon-untagged.png"), Path("icon-srgb.png")): with Image.open(path) as image: pixel = image.convert("RGBA").getpixel(point) print(f"{path.name}: RGB {pixel[:3]}, alpha {pixel[3]}") 

The exact RGB values depend on the input pixel and profile. The untagged branch deliberately drops the source metadata for this comparison. With an existing optimizer, check the exported file for color signaling too. A PNG can declare sRGB through its own sRGB chunk even when an embedded ICC profile is absent.

What to check after exporting from IconVectors

IconVectors can export SVG icons as PNGs. The Pillow test above isolates what can happen in a later optimization step. If your pipeline strips metadata, check an exported PNG before and after that step in the viewer or app where it will actually appear.

For a pipeline that expects sRGB, convert any input that uses a different color space before stripping its color metadata. In a pixel check, read RGB and alpha at the same coordinate in both files. In a visual check, put the icon next to the UI colors it needs to match. A status icon is a useful test case because the neighboring label or badge gives you a reference for the intended green.