Frank contacted me because my image component CFX_JImage takes ages to resize large files. Here was my reply after some testing:
Hi Frank,
I just did some tests and here is the low-down.
--------------------------------------------------------------------------------------
1. ColdFusion seems to not like allocating large amounts of memory for CFX tags
and this seems to be what is causing the problem. On may laptop, resizing and image that
is 2000px in width is no problem. 3000 just hangs for me.
2. However JImage can be executed as an command line process - calling it this way from
ColdFusion with the 3000px image does work perfectly but takes 5 seconds with a JPEG file
and 3 seconds with a BMP file.
3. I revised the code and can tell you that the reason it takes so long is that for high quality
output I am actually doing a RESAMPLE and not just a resize.
The means that the output is of a much much higher quality than a simple pixel resize
but takes longer to do.
4. I have added an extra attribute, quickResize to do a quick resize for you!
With quickresize="yes" turned on, resizing a 3000px BMP file now takes less than
300 milliseconds to do the pixel resize!!!
5. However even with the new quickresize turned on, the resize of a 3000px JPEG file still takes ages; this is because JPEGs need more memory to be read and ColdFusion is imposing an upper limit on the allowed Java Heap Space.
When jimage is called from the command line, jimage executes the resize on the 3000px JPEG file in 1 second with the quickresize option turned on.
--------------------------------------------------------------------------------------
SUMMARY:
In summary, I have made resizes very fast by adding the quickresize="yes" option.
However with large JPEGs, ColdFusion still takes ages to resize these files due to in-memory restraints. However executing JImage externally to ColdFusion works ok even with large JPEGS.
--------------------------------------------------------------------------------------
THE SOLUTION:
1. Extract the attached file JImageQuickStart.zip to your desktop.
To get the resizequick option in cfx_jimage:
1. Look for the new jimage.jar file in the extracted folder - its in dcCom\components\jimage\.
2. Stop coldfusion and then copy the new jimage.jar file over the existing jimage.jar file
3. Start coldfusion again.
However loading large JPEG files will still upset ColdFusion due to the maximum memory heap.
The best solution is to execute jimage as an command line program.
Fortunately I made a wrapper to make this easy:
1. Copy the dcCom folder into the root of your application
(i.e. where your application.cfm file is).
2. Copy the "dcCom.cfm" to whereever you are calling cfx_jimage.
3. Change the syntax of the way you call JImage from
<cfx_jimage ...>
to
<cf_dccom component="jimage" ... ></cf_dccom>
So instead of:
<cfx_jimage file="#loc#z6.jpg" outfile="#loc#z_out.bmp"
action="resize" width="175" timeout="6" quickresize="yes">
use:
<cf_dccom component="JImage" file="#loc#z6.jpg" outfile="#loc#z_out.bmp"
action="resize" width="175" timeout="6" quickresize="yes"></cf_dccom>
Don't forget the quicksize. You are still limited to a size of about 2600px width for JPEG image. Other file formats seem ok.
You could attempt to resize this, it if fails after the 6 second timeout.
I've been at this all morning - I want you to be a happy customer. Must get back to work now.
Best Regards,
Peter