Error resizing a JPG with ColdFusion?

This post is more than 2 years old.

I exchanged a few emails yesterday with Steve concerning an issue he was having creating thumbnails in ColdFusion. He had a query of filenames, many of them, and was looping over each and shrinking them down:

<cfloop query="employee"> <cfif len(photo_path)> <cfimage action="resize" source="#wwwroot#\photos\#userid#\#photo_path#" destination="#wwwroot#\photos\#userid#\thumbnail.jpg" overwrite="yes" height="20%" width="20%"> </cfif> </cfloop>

This worked consistently until he got to the 12th record. Then he would get the following:

Error Occurred While Processing Request
attempt to read data outside of exif segment (index 10080 where max index is 9905)

I confirmed the issue on my server with his 'bad' image, but unfortunately didn't have any luck finding a solution with Google. I did find though that ColdFusion 9 worked with the file perfectly.

Luckily Steve was a better Google Ninja than I, and he found this article from the Webapper folks: ColdFusion 8 EXIF Error

The technique described in the article (getting and deploying an updated JAR) worked perfectly for Steve. Just sharing this in case others run into it as well.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by James Allen posted on 7/15/2009 at 4:18 PM

Thanks for posting this Ray. I don't know if you remember but we had a brief discussion over Twitter about the image resizing problems I was getting in my app. CF8 would fail to resize certain JPG's and it appeared to be related to DPI. I.E a certain 96DPI image wouldn't resize but if it was changed to 300DPI it would.. Very weird.

Anyway, I don't know if this particular patch will fix my issue but it's worth a try.

BTW, I did find a way around it which I was thinking of implementing. The fix is to first convert the JPG to a BMP and then resize to a new JPG.

Another technique to consider if people are getting image resizing issues working on JPG's.

Comment 2 by Benoit HEDIARD posted on 7/15/2009 at 4:55 PM

I confirm that most of cfimage resize issues can be solved by writing the JPG to BMP and then working on the BMP version.

Comment 3 by Steve Caldwell posted on 7/15/2009 at 5:13 PM

Thanks for posting this Ray. Your blog post is now the ONLY google result for this error message+cfimage.

It looks like CF9 uses the metadata-extractor-2.4.0-beta-1.jar, whereas CF8 used metadata-extractor-2.2.2.jar.

The fix called for metadata-extractor-2.3.1.jar, which I did, but maybe updating to the 2.4.0 beta is best, to avoid any other problems...since the folks at Adobe saw it stable enough to include it in CF9.

IMO, .bmp files are terrible for web use...hope this saves you from having to convert to that clunky format.

I never realized how much data is stored "behind the scenes" on a digital photo! Better stick to film for those less-than-public photos...

Comment 4 by James Allen posted on 7/15/2009 at 5:25 PM

The bmp is only used prior to resizing to the final jpg format. It is then deleted.

Comment 5 by Steve Caldwell posted on 7/15/2009 at 5:27 PM

Oh ok. that makes sense...
Well maybe this will save you a step and half second of processing time :)

Comment 6 by James Allen posted on 7/15/2009 at 5:30 PM


Ah defo.. I'm hoping the fix you found will be the solution to my issues. The only reason I'm not sure is that when I got resize problems I wasn't getting any errors.

I will upgrade the extractor just for good measure though and see if the problem reoccurs before having to recode my image resizing component.


Comment 7 by Russ posted on 7/15/2009 at 5:46 PM

For awhile I've had cfimage issues with uploading a JPG, resizing it, then re-saving it with the same name.

The fix I've been using is to upload the image to a junk folder, re-size it and save it as a new image in the actual folder, then delete the original. For some reason this works.

It seemed to be happening on all of our cfimage JPG uploads (obviously, re-using code where possible).

Comment 8 by Daniel Budde posted on 7/21/2009 at 9:35 PM

@James & Ray

Ray, when I had that issue with certain images taking an unearthly amount of time to resize, I was ultimately able to accomplish the same fix as James. I have an Image Gallery that I create thumbnails for, so I first create a BMP version of the image and then derive my thumbnail from that. Took my 75 second conversion time on some of these images down to 1 or 2 seconds.