IE8, ColdFusion, and Color Profiles

We do a massive amount of image processing on LandsofAmerica.com. Our image processing scripts take uploaded photos from realtors and create multiple versions at different sizes for use throughout our applications. This has been working without a hitch for ages. Unfortunately, IE8 was released...

We did a lot of testing with IE8 before it was released to make sure everything on our site was working well. Unfortunately, after the official release of IE8, and the subsequent push of the browser out to the general populace, we started to get odd reports from users that the colors of the photos they were uploading wasn't right. Take a look for yourself:

badcolor-horse.png

Something was definitely not right. We weren't seeing this with every image, and the problem didn't exist in any other browser. And while the horse looked pretty bad, this photo really blew me away:

badcolor-house.png

I started searching Google for the cause of the problem, and found that IE8 doesn't deal well with jpg images that contain CMYK color profiles. Unfortunately I couldn't find anything specific to the image profile issue and ColdFusion. I found lots of suggestions to use third-party components to handle image resizing instead of built-in ColdFusion functionality, but that's just not how I roll. So back to Google.

Angela found a blog post by David Sirr that discussed saving an image out as a PNG before doing any processing to get rid of potential corrupt image data (like funky "colour profiles") that could cause CF to hang when resizing an image. The basic premise is that you save the image to disk as a PNG (which discards all color profile data), immediately read it back in, do your editing, and then save it back to disk as a JPG when you're done (after cleaning up your PNG mess of course).

After adding three lines to my image processing script:

  1. Save to disk as PNG
  2. Read back into memory
  3. Delete PNG

After reprocessing the images, our crazy alien world images were back to normal.

Posted by Daniel Short on Nov 12, 2009 at 6:28 PM | Categories: ColdFusion -

1 Comments

Gary F

Gary F wrote on 04/28/13 7:35 PM

I realise this post is 4 years old but nevertheless found the tip about saving out as PNG very useful. It's an uncomplicated solution to an annoying problem. Thank you.