Weblog entry #172 for simonw
#172
PNG rendering problems? Use pngcheck and pngcrush
Posted by simonw on Wed 27 Jun 2007 at 13:09
The usual complaint about PNG rendering in browsers is to do with alpha channel rendering. PNG rendering has other potential pitfalls.
Today I had a problem with part of a page layout that was composed of three graphics, left, right, and a background tile between them. In Firefox they rendered as expected, in IE6 and IE7, one of the graphics looked a tad pale.
The cause of this was one of the graphics had been redone, and had a gamma correction inconsistently applied between the graphics. Most of the tools failed to show this difference, but "pngcheck" (Debian Package pngcheck) clearly shows a "gAMA" section (when using "pngcheck -v test.png", line beginning "chuck gAMA").
I fixed it by the simple expedient of loading the PNG in the GIMP and saving it without gamma correction.
During my research I also found the handy utility "pngcrush" (Debian Package pngcrush), which tries out different lossless compression filters on your PNG image data till it finds the most efficient, and then creates a PNG with that filter (i.e. as small as possible). "pngcrush" can also be used to remove gamma correction data, but they recommend against this - presumably as they think gamma correction may help sometimes! pngcrush outperformed the various proprietary tools our webmaster uses for PNG creation, not a huge gain for us, but if I was serving a lot of PNG files....
http://hsivonen.iki.fi/png-gamma/
http://www.libpng.org/
Today I had a problem with part of a page layout that was composed of three graphics, left, right, and a background tile between them. In Firefox they rendered as expected, in IE6 and IE7, one of the graphics looked a tad pale.
The cause of this was one of the graphics had been redone, and had a gamma correction inconsistently applied between the graphics. Most of the tools failed to show this difference, but "pngcheck" (Debian Package pngcheck) clearly shows a "gAMA" section (when using "pngcheck -v test.png", line beginning "chuck gAMA").
I fixed it by the simple expedient of loading the PNG in the GIMP and saving it without gamma correction.
During my research I also found the handy utility "pngcrush" (Debian Package pngcrush), which tries out different lossless compression filters on your PNG image data till it finds the most efficient, and then creates a PNG with that filter (i.e. as small as possible). "pngcrush" can also be used to remove gamma correction data, but they recommend against this - presumably as they think gamma correction may help sometimes! pngcrush outperformed the various proprietary tools our webmaster uses for PNG creation, not a huge gain for us, but if I was serving a lot of PNG files....
http://hsivonen.iki.fi/png-gamma/
http://www.libpng.org/