Tuesday, May 17, 2011

How to fix image color dept problem or why does this picture do not work in IE

We have all stumbled upon a problem when certain pictures (jpegs) work perfectly in firefox, chrome ... but not in IE (any version). The problem is that color depth in image header is different than the actual color depth. So if i.e. actual color depth of a picture is 24bit but header reports that it is 32bit, this picture will not display in IE. If you are using Linux, you are in luck, because that can simply be fixed.

I've found this site with tools needed (there is also an ubuntu package if you are using ubuntu). To detect the problem use:

jpeginfo -c -merronly Downloads/test.jpg

If there is an error, you will get something like:
Downloads/test.jpg  594 x 420  32bit 
Exif  N  174956  Unsupported color conversion request  [ERROR]

To fix the problem simply use imageMagic:

#convert it to png
mogrify -format png Downloads/test.jpg
#and then back to jpg
mogrify -format jpeg Downloads/test.png
Post a Comment