Why PNG Colors Look Different: Gamma, sRGB and ICC Chunks
Explain gAMA, sRGB, iCCP conflicts, application behavior and a repeatable normalization test.
Why PNG Colors Look Different
Two PNG files with identical pixel values can render with visibly different lightness or saturation. The cause is not the image data itself but three optional metadata chunks that describe how those pixel values should be interpreted. When these chunks conflict, are absent, or are ignored by viewing software, the displayed colors shift.
This article covers the gAMA, sRGB, and iCCP chunks, how applications resolve conflicts between them, and a repeatable test to determine what a specific PNG instructs software to do.
The Three Chunks That Control Color
The PNG specification (W3C PNG-3) defines three chunks relevant to color appearance:
gAMA(gamma): A single floating-point value representing the gamma of the display for which the image was encoded. A value of 1/2.2 (approximately 0.45455) corresponds to a typical sRGB display; a value of 1.0 indicates linear-light encoding. The chunk tells a decoder to apply a power-law transfer function to the sample values.sRGB(sRGB color space): Signals that the image samples conform to the sRGB color space and specifies a rendering intent (perceptual, relative colorimetric, saturation, or absolute colorimetric). Per the specification, whensRGBis present,gAMAandcHRMchunks should not also be present because they are redundant. If they are present, their values may contradict the sRGB definition.iCCP(embedded ICC profile): Contains a complete ICC color profile that describes the transformation from the image’s sample values to a profile connection space. When an application performs full color management,iCCPoverrides bothgAMAandsRGB. The profile can describe any color space, including sRGB, Display P3, or Adobe RGB.
What Happens When Chunks Conflict
A PNG containing both an sRGB chunk and an iCCP profile that describes a different gamut creates an unresolvable ambiguity. The specification states that sRGB and iCCP should not both appear (PNG-3, §11.3.3), but encoders sometimes write both.
Observed failure modes:
- Some viewers read
sRGBfirst and ignore the embedded profile. - Others read
iCCPand apply it, ignoringsRGB. - A subset of viewers apply the
iCCPprofile and then also apply gamma from agAMAchunk, doubling the correction.
Hard limit: If an image was encoded without color management and its sample values were written with no associated color space, no chunk can recover the intended appearance. The chunks describe the encoding intent; they cannot reconstruct information that was never recorded.
Conversion loss: Converting a PNG to another format (JPEG, WebP) without preserving or explicitly remapping its color chunks discards the color intent. The target format may apply different default assumptions, producing a different visual result from the same sample values.
How Applications Resolve Color Chunks
Different software applies different precedence rules when multiple color chunks are present.
Browsers (Chrome, Firefox, Safari)
- If a valid
iCCPprofile is present, it is used. - If no
iCCPis present butsRGBexists, sRGB is assumed. - If only
gAMAexists, gamma correction is applied using that value. - If no color chunks exist, sRGB with a gamma of approximately 2.2 is assumed.
Image Editors (Photoshop, GIMP)
- Photoshop: Uses
iCCPif present; otherwise falls back tosRGB. If neither exists, it prompts the user to assign a profile. It ignoresgAMAwhen a profile orsRGBchunk is present. - GIMP: Follows a similar order but respects
gAMAwhen no profile orsRGBchunk is found.
Operating System Previews (macOS Finder, Windows Explorer)
- macOS: Uses embedded
iCCPprofiles for full previews. Thumbnail generation may fall back to sRGB. - Windows: Historically ignored all color chunks in thumbnails and displayed raw sample values. Recent versions apply sRGB when no profile is found but may still skip
gAMA.
Mobile Platforms (iOS Photos, Android Gallery)
- iOS: Respects
iCCPandsRGB. May ignoregAMAwhen a profile is present. - Android: Behavior varies by manufacturer and gallery app. Some implementations ignore all color chunks and render raw sample values.
Repeatable Normalization Test
This test identifies which chunks a PNG contains and how different viewers interpret them.
Prerequisites: pngcheck or ImageMagick’s identify, and a color-managed image editor capable of assigning an sRGB working space.
Step 1: Inspect Existing Chunks
pngcheck -v yourfile.png
Examine the output for lines containing sRGB, gAMA, and iCCP. Note which are present and their values.
Step 2: Create a Known Baseline
- Create a new document in an editor with the working space explicitly set to sRGB (e.g., "sRGB IEC61966-2.1").
- Fill the document with a solid patch of RGB(128, 128, 128).
- Export as PNG with only the
sRGBchunk embedded. Do not embed an ICC profile.
Check: Open this baseline PNG in a browser. The gray patch should appear neutral against a CSS #808080 background if the browser honors sRGB.
Step 3: Compare Across Viewers
Open the baseline PNG in: - A browser - A mobile device’s default photo viewer - Two different image editors
If the gray patch appears neutral in all viewers, each is interpreting the sRGB chunk consistently. If it appears lighter or darker in one viewer, that viewer is ignoring the chunk or applying its own gamma assumption.
Step 4: Add a gAMA Chunk
convert baseline.png -set gamma 0.45455 gamma_test.png
Open gamma_test.png in the same viewers. If the gray patch shifts relative to the baseline, the viewer is applying the gAMA value on top of the sRGB interpretation. This indicates a double-correction bug.
Step 5: Replace sRGB with an iCCP Profile
convert baseline.png -strip -profile /path/to/sRGB.icc icc_test.png
The -strip operation removes all metadata chunks; the -profile operation embeds only the specified ICC profile. Verify with pngcheck that sRGB and gAMA are absent and iCCP is present.
Open icc_test.png across the same viewers. If the gray patch matches the baseline, the viewer is using the embedded profile correctly. If it does not match, the viewer is either ignoring iCCP or applying an additional transform.
Resolving Chunk Conflicts
When a PNG contains conflicting chunks, the most reliable approach is to retain only one authoritative color description.
Order of preference for portability:
- Embed only an
sRGBchunk with noiCCPand nogAMA. This is supported by all modern browsers and many mobile viewers. - For wide-gamut content (Display P3, Adobe RGB), embed only an
iCCPprofile and removesRGBandgAMA. - For linear-light or other non-sRGB gamma encodings, use only
gAMAand removesRGBandiCCP.
Example using pngcrush:
pngcrush -rem gAMA -rem cHRM -rem iCCP -sRGB 1 input.png output.png
Limitation: Removing an iCCP profile discards the exact gamut mapping. If the sample values were authored in a wide-gamut space and an sRGB chunk is substituted without first converting the sample values to sRGB, colors will be incorrect on any viewer that interprets the chunk. The sample values must be converted to the target space before the profile is removed.
Summary of Hard Limits
- No chunk can restore color intent that was not recorded at encoding time.
- No viewer can display color correctly if it ignores all color chunks.
- The intended appearance of a PNG cannot be recovered if the file has been re-encoded without its original color metadata.
- A PNG containing both
sRGBandiCCPwill produce inconsistent results across applications that prioritize one over the other.