Fixing PNG color matching for Safari and IE

August 7th, 2008 in Howto

I spent a few minutes tonight figuring out why PNG files display differently on Safari (and IE6/7). It’s related to both gamma and colour space.

A partial solution:

pngcrush -rem cHRM -rem gAMA -rem iCCP -rem sRGB -d fixed/ *

The real solution:

There is no way of making PNG images that match CSS colors in all PNG-supporting browsers. This reduces the usefulness of the otherwise excellent image format. If the image colors and the colors defined in a style sheet need to match, it is safer to use GIF or JPEG. If you want to use PNG and don’t care about older browser versions (pre-Tiger Safari in particular), the best course of action is removing all the color space information from the PNG files. If you only want a match with the background color, you could make the background a PNG image as well. –The Sad Story of PNG Gamma “Correction”