1

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">
Nebu
  • 1,753
  • 1
  • 17
  • 33
  • Try reading the image file using `cffile action="read`, then calling `info = imageInfo(local.imageread)`. You should be able to get the width and height from there. – John Whish Feb 29 '16 at 17:08
  • @Nebu Which OS are you using? If Windows, I can provide you with command line alternatives that work with ColdFusion 6-2016 and are much faster than the native built-in functions (and don't throw errors when encountering CMYK images). – James Moberg Feb 29 '16 at 18:21
  • 1
    @JohnWhish this does not work. imageInfo requires an image object as parameter. – Nebu Feb 29 '16 at 18:30
  • @JamesMoberg The os is windows. If you could provide me with a command line alternative this would be great. – Nebu Feb 29 '16 at 18:31
  • @Nebu Exiv2 is a free portable command line utility. It takes 15-47ms to get full EXIF data compared to ImageGetEXIFMetaData()'s 500-920ms. http://gamesover2600.tumblr.com/post/139435793234/coldfusion-udf-for-exiv2-faster-exif-image – James Moberg Feb 29 '16 at 21:19
  • I started using this because, in addition to being faster, I had also encountered some iPhone4S JPGs that ColdFusion 9 & 10 couldn't read/open. – James Moberg Feb 29 '16 at 21:20
  • @Nebu If you need to resize/rotate/convert images, consider GraphicsMagick. Flickr & Etsy use it. http://gamesover2600.tumblr.com/post/125766251344/graphicsmagick-coldfusion-custom-tag – James Moberg Feb 29 '16 at 21:21

1 Answers1

1

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">
James Moberg
  • 4,360
  • 1
  • 22
  • 21
  • Based on your suggestion I remembered i used to work with ImageMagick in a past project. Very similar to GraphicsMagick. – Nebu Mar 01 '16 at 13:52
  • I choose to standardize on GraphicsMagick after reading multiple reviews regarding performance. The command line API also looked easier to work with. – James Moberg Mar 01 '16 at 17:28