Elliott's Blog | Life Through Math, Algorithms and Code

Jan/09

14

cfimage and ImageScaleToFit on Large Images Pegs CPU

I was working on the new profile picture feature of the registration and CFUnited 2009 website when I ran into an issue where a user uploaded a 2112 x 2816 (2MB) photo.

This seemed to cause file locking issues in cfimage which I was told were addressed by CF 8.0.1 Cumulative Hot Fix 1. I applied the hot fix and everything seemed to work, but then when I started testing with the large file again the CPU would jump to 100% and the request would never seem to finish. I tried all kinds of things, and nothing I did seemed to make a difference.

Finally I tried the “highestPerformance” interpolation and the requests started finishing hundreds of times faster. Any other interpolation algorithm seems to cause the thread to lock up.

I’ve fixed this in our code with:

<!--- 
	CF8 will peg the CPU to 100% and this thread will seem 
	to hang for minutes on large images if we don't choose 
	highestPerformance.
--->
<cfif getSize("kilobytes") gt 375>
	<cfset arguments.interpolation = "highestPerformance">
</cfif>

What’s most odd is that the issue only appears on Windows on the production server. On my Macbook I can choose a different algorithm and get a nice resize without hanging the request.

Production server is Java 1.6 u11, CF8.0.1 HF2, Windows Server 2003

Anyone have any ideas?

No tags

6 comments

  • Azadi Saryev · January 15, 2009 at 1:11 am

    I had (and still have) the same issue, I believe…
    imageScaleToFit() function in CF8 with HF1 and CFIMAGE HF crashes the server every time on large jpeg images. I ended up un-installing both HF1 and CFIMAGE hotfix, which solved imageScaleToFit crashing, but, of course, re-introduced the image locking bug… but there is a work-around for that out there (http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1358449).
    I have posted the issue in HoF cf-talk list a while ago with more details: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:57440

    I do not see HF2 on the cf hotfixes page on adobe.com… where did you get it (if it is not a typo in your prod server specs)?

    Azadi

    Reply

  • Seb Duggan · January 15, 2009 at 6:53 am

    Much as I wanted to love the cfimage features in CF8, once I started using it on a production site where users would upload images which were then resized, I went straight back to Efflare’s ImageCR. So much faster…

    I do however use cfimage to create CAPTCHAs.

    Reply

  • Author comment by Elliott · January 17, 2009 at 3:25 am

    @Azadi

    I think they forgot to update the hotfix listing. It does exist:

    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403781

    Reply

  • mex · March 23, 2009 at 6:39 pm

    Hi Elliott,

    We have some apps that do a lot of image manipulation, and we had problems with the cf image functions when we upgraded one of our servers to 8.0.1. So we upgraded to cumulative hotfix 1. Then we started getting this problem (100% cpu spikes).

    We assumed it would be fixed when we recently discovered hotfix 2. Which was buried deep in the adobe site – 6 months later it’s still not on the coldfusion ‘hotfixes page’?

    Anyway, we downgraded back to cf 8.0.0, and even under heavy load we don’t have any problems with any of the image functions, luckily we don’t use anything that is broken in 8.0.0

    I’m really dissapointed Adobe couldn’t fix this, it’s been ages. But if you need performance out of imagescaletofit without sacrificing image quality I’d give 8.0.0 a go :)

    Cheers
    Mex

    Reply

  • Jay Westercamp · August 18, 2009 at 4:13 pm

    I am too having this problem. Not on http://www.ATVManualStore.com but on a government site I develop for. We are on 8.0.1. Are there any security issues w/ going back down to 8.0? I am going to try the hotfix 2 before we downgrade CF.

    Reply

  • James Moberg · July 28, 2011 at 7:40 pm

    Two years later and nothing has really changed even with CF9. I’ve found that using CFX_OpenImage rescales images about 75-90% faster and creates images that are about 64-72% smaller than CFImage. Simply getting the image dimensions is about 96% faster.
    http://www.kolumbus.fi/~kr0626/cfx_openimage/
    (NOTE: Only available for Win32)

    Reply

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me