coldfusionimagemagickjmagick

How to work with ImageMagick from ColdFusion


ColdFusion has a great cfimage tag that works perfectly. However, it doesn't allows vector formats to be manipulated. This caused me to continue searching for 3rd party tools to do some "image magic".

I decided to try ImageMagick with ColdFusion. I've read couple of posts that was saying 'I used to work with ImageMagick from ColdFusion for X years'. This is inspiring, but not particularly useful when bumping into problems.

I've tried the following:

  1. cfexecute with arguments to run command-line 'convert' command. ColdFusion page produces nothing - just an empty page. Images are not converted. No exceptions or text being out to browser. ImageMagick command 'convert image.eps image.jpg' runs perfectly from Windows command line, but not from ColdFusion.

  2. Im4java and JMagick wrappers to run IM commands directly from Java objects. I created Java objects with CreateObject function and was trying to execute it's methods, but got only different types of Java errors like 'cannot convert image.jpg to integer'.

Any suggestions welcome.

Thanks!

PS: my first 'stackoverflow' :)


Solution

  • After some tries and fails, I made ImageMagick (IM) work for me. Let me briefly describe how to work with ImageMagick from Coldfusion:

    1. Have ImageMagick and Ghostscript installed on box. Ghostscript is used for vector graphics manipulation.
    2. Make use of CFEXECUTE tag to call IM with parameters:

      <cfexecute name="#FullIMPath#" timeout="60" arguments="""#ExpandPath(filename1)#"" ""#ExpandPath(filename2)#""" />

    Comments:

    a. Write full path to one of ImageMagic executables (for example, convert.exe) in 'name' attribute.

    b. Write full paths for source and target images. Please note additional quotes - if full path has spaces (C:\Program Files), you have to surround each image name in pair of quotes. Since Coldfusion parses 'arguments' attribute, you have to screen a quote with additional quote, like this - ""C:\Program Files\"".

    c. Use timeout attribute, to allow some time for ImageMagic to produce results before Coldfusion goes further with template execution.

    Thank you all for answers and interest.

    PS: Additional hints: