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:
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:
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:
- Save to disk as PNG
- Read back into memory
- Delete PNG
After reprocessing the images, our crazy alien world images were back to normal.