coldfusioncoldfusion-9cfimage

Cfimage info very slow


I have the following script in coldfusion 9:

<cfimage action="info" source="E:\....\image.png" structname="local.imageInfo">

The image is on a local drive. This action takes up about 4 seconds. File is about 800kb in size (300 dpi, png). This seems abnormal to me. Is there a way so speed this up? I only need the with and height of the image.

Btw doing a simple read action on the image is performed instantly

<cffile action="read" FILE="E:\....\image.png" VARIABLE="local.imageread">

Solution

  • If you are using Windows and ColdFusion 8+, consider using the free, portable command-line programs Exiv2 and GraphicsMagic. Exiv2 can read/write EXIF data using the command line and is faster than built-in CF functions.

    http://www.exiv2.org/

    GraphicsMagick is much faster at converting, resizing, cropping, rotating, generating thumbnails, not throwing an error when reading a CMYK image, etc.

    http://www.graphicsmagick.org/

    I've written ColdFusion 8-2016+ custom tags as wrappers for both portable command-line programs.

    http://gamesover2600.tumblr.com/post/139435793234/coldfusion-udf-for-exiv2-faster-exif-image

    <CFSET ImageFilePath = "c:\test.jpg">
    <CFDUMP VAR="#Exiv2(imageFilePath)#">
    

    http://gamesover2600.tumblr.com/post/125766251344/graphicsmagick-coldfusion-custom-tag

    <CFSET ImageIn = "c:\test.jpg">
    <!--- Identify - Get basic info (Exiv2 is better/faster) --->
    <CF_GraphicsMagick action="Identify" infile="#ImageIn#" result="GM_Identify">
    <CFDUMP VAR="#GM_Identify#" label="GM_Identify">
    
    <!--- Optimize (common settings to reduce filesize) --->
    <CF_GraphicsMagick action="Optimize" infile="#ImageIn#" outfile="#replace(ImageIn,'.jpg','_optimize.jpg')#" result="GM_Optimize">
    
    <!--- ResizeWidth (Resize to defined width --->
    <CF_GraphicsMagick action="ResizeWidth" infile="#ImageIn#" width="200" outfile="#replace(ImageIn,'.jpg','_resizeWidth.jpg')#" result="GM_ResizeWidth">
    
    <!--- AspectCrop (Similar to ImageUtils.cfc) --->
    <CF_GraphicsMagick action="AspectCrop" Infile="#ImageIn#" outfile="#replace(ImageIn,'.jpg','_aspectCrop.jpg')#" width="100" height="100" quality="90" result="aspectCrop">