ColdFusion 8.0.1 Bug Coldfusion.Image.ImageWriter $ ImageWritingException

Posted July 17, 2008 at 9:34 AM

Tags: ColdFusion

I just came across a known bug in ColdFusion 8.0.1. Apparently, sometimes the ColdFusion image functions don't play nicely with JPG image files and throw the following error:

An exception occurred while trying to write the image. Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : coldfusion.image.ImageWriter$ImageWritingException: An exception occurred while trying to write the image.

Some quick googling found that there was a Hot Fix available for ColdFusion 8.0.1 image functions. I figured I would post it here in case anyone was running into the same problem.

ColdFusion 8.0.1 CFImage / Image Functions Hot Fix

ColdFusion 8.0 And Later Hot Fixes

I installed the above ColdFusion 8.0.1 Image hot fix, restarted my ColdFusion service, and the image that was breaking my application started working again.

Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page




Reader Comments

Jul 17, 2008 at 1:36 PM // reply »
7 Comments

Hey Ben, I've been working with the jpg issues for a while. I've noticed that some jpg's don't play nice even after the hotfixes are applied.

It may be a hack, but I got fed up and had to do something....I'm converting the jpg's to gif's (usng CFIMAGE action="convert") after they're uploaded and then doing the CFIMAGE manipulation (resizing etc) on them. Its an extra step, but it's working like a charm for my site.

I hope this helps!


Jul 17, 2008 at 1:47 PM // reply »
6,515 Comments

@Dan,

Interesting hack. Unfortunately, converting a large JPG to a GIF will increase the file size greatly (in theory)? But, good to have at least on solution till they iron out the kinks.


Ben
Sep 18, 2008 at 5:10 PM // reply »
1 Comments

Thanks for the Tip, this problem was driving me crazy, 1 jpg works fine, then next one does not!

Your site rocks!


Nov 17, 2008 at 1:08 PM // reply »
3 Comments

I had the same problem, and the hot-fixes didn't seem to help. Not quite sure where the client was getting their jpgs from :)

As a fix, I found that saving the image to disk and then reloading it worked. The extra step seemed to convert the jpg to a format that didn't have the problems.

It's not perfect, as it slows things down and probably reduces image quality. It required the least effort though, and doesn't have the issues associated with converting the image format to gif.


Dec 22, 2008 at 1:26 AM // reply »
3 Comments

Thanks so much!!!


Mar 1, 2009 at 2:48 AM // reply »
1 Comments

@Gareth, can you explain further how you got this to work. the hotfix is not working for me either and converting to .gif's is too much load and file size. what do you mean by saving the image to disk and then reloading it. can you provide sample code?


Mar 1, 2009 at 1:42 PM // reply »
3 Comments

It's while ago, but I think I just used cfimage to save the file without modification.
I then reload the new image and do whatever manipulation that's needed.
It doesn't fix all images, but reduced a lot of the problems


Mar 8, 2009 at 7:18 AM // reply »
12 Comments

Thanks Ben, that did the trick for me, I applied the patch and the jpgs are now working.


Apr 7, 2009 at 5:56 AM // reply »
1 Comments

Cheers, that was a lifesaver, spent a week or two on and off on this problem


Jun 16, 2009 at 8:34 AM // reply »
2 Comments

I'd still be starting at a page of code if it wasn't for this post: I had an issue with three file uploads in one form that stopped working after we upgraded to 8, thanks!


Jun 16, 2009 at 8:39 AM // reply »
6,515 Comments

@Garry,

Glad to help :)


Jun 16, 2009 at 9:36 AM // reply »
7 Comments

I commented earlier about converting .jpg's to .gif as a workaround. I've since learned that my .jpg problems stemmed from trying to constrain both the height and width of the .jpg using CFIMAGE action="resize". Sometimes my users would upload a .jpg (book covers in this case) and the dimensions were such that constraining it too far "out of whack" from the original size would cause the page to break. I've since removed the "width" attribute of the CFIMAGE tag, but I still explicitly set the "height"...the width is constrained automagically (thanks CF)...it works perfectly except for the occasional user that uploads something really funky...like a banner image rather than a book cover...lol :-)


Jun 16, 2009 at 9:46 AM // reply »
6,515 Comments

@Dan,

Good tip to know. Thanks.


Jun 16, 2009 at 10:23 AM // reply »
2 Comments

I found that using the cfimage info to determine what's been uploaded seemed to be best, so I have something like this

<cffile action="UPLOAD" filefield="upload2" destination="#application.path#www\alt_images\" nameconflict="MAKEUNIQUE">
<cfimage action="info" source="#application.path#www\alt_images\#cffile.ServerFile#" structname="info">
<cfif info.width gte info.height>
<cfimage action="resize" source="#application.path#www\alt_images\#cffile.ServerFile#"
destination="#application.path#www\alt_images\thumbs\#cffile.ServerFile#" height="" width="100" overwrite="yes">
<cfelse>
<cfimage action="resize" source="#application.path#www\alt_images\#cffile.ServerFile#"
destination="#application.path#www\alt_images\thumbs\#cffile.ServerFile#" height="100" width="" overwrite="yes">
</cfif>


Jun 16, 2009 at 11:10 AM // reply »
7 Comments

@Garry ....awesome idea! thanks for the tip!


Aug 6, 2009 at 3:42 AM // reply »
2 Comments

The cumulative hot fix 2 for CF 8.01 includes this hotfix and a pile of other fixes.

http://kb2.adobe.com/cps/403/kb403781.html

You will also want the hotfix that fixes a vulnerability in FCKEditor (it is not included in the patch above).

http://www.adobe.com/support/security/bulletins/apsb09-09.html


Aug 27, 2009 at 12:33 PM // reply »
1 Comments

Another interesting twist on this issue for the benefit of anyone else who might have trouble. We were using CF8 to write images across the network and had to alter the run-as user for the CF instance in order for the image writing to work.

However, when re-starting the instance via JRun Admin, those permissions were not set - resulting in the aforementioned exception. Re-starting the Windows service that CF was running under fixed the issue.


Sep 2, 2009 at 9:49 AM // reply »
6,515 Comments

@Scott,

Thanks for the links. I need to check to see where my server is on these updates.

@Jeff,

Very interesting situation you got going on there.


Nov 10, 2009 at 10:27 PM // reply »
1 Comments

Another workaround for those "stubborn" jpgs: use <cffile action="readbinary" ...> and feed the variable (name) to <cfimage action="resize" ...>

This worked for me =)


Nov 15, 2009 at 10:34 PM // reply »
6,515 Comments

@Marxmannn,

Oh very interesting; that's great to know about.


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 20, 2009 at 5:38 PM
Learning ColdFusion 8: CFImage Part I - Reading And Writing Images
Hi Ben, Great article. I've been looking around to see if ColdFusion image engine can programatically create the following "wrap around" effect: http://www.creativepro.com/article/photoshop-s-she ... read »
Nov 20, 2009 at 5:35 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Dave: I talked to Gert he suggested: <cfhttp method="get" url="http://{some cf website}" result="stuff" addtoken="yes" /> Note the addition of cfhttp attribute addtoken. That should persist y ... read »
Nov 20, 2009 at 5:23 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Todd, Ahh, gotcha, yeah that makes sense. ... read »
Nov 20, 2009 at 5:17 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
Ben, sorry if I didn't make this clear. You can make it work like that if you want, just put <cfset session.foo = 1> (and <cfset application.foo = 1>) in your OnRequestStart() and it reve ... read »
Nov 20, 2009 at 5:07 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Todd, I have seen tidbits about the way Railo handles session. I can understand that it lazy-loads sessions, but I also think that I might make some things more complicated. For example, often tim ... read »
Nov 20, 2009 at 4:53 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
Ben, you can ramp up the security by turning on J2EE session which gives you a third set of numbers other than CFID/CFTOKEN. There's a reason why ACF put this in place (other than just session replic ... read »
Nov 20, 2009 at 4:52 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
Case in point, Ben, you may not be aware of this, but in Railo - OnApplicationStart() & OnSessionStart() act differently than in ACF. ACF does: OnApplicationStart (1st hit) OnSessionStart (1st and e ... read »
Nov 20, 2009 at 4:46 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Todd, That's understandable. I am not sure if this really leaves any more security holes than the fact that using old cookie-based CFID / CFTOKEN values will create a new session using the old CFI ... read »