Question

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' :)

Was it helpful?

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:

  • ImageMagick offers many formats to work with - from regular JPEGs to Photoshop *.psd files. However, for vector formats like Encapsulated Postscript *.eps, you need to have Ghostscript installed;
  • you may work with Adobe PDF and Adobe Illustrator (*.ai) formats with small hack - rename them to *.eps and let ImageMagick treat them like Encapsulated Postscript vector files. This allows at least to convert vector files to bitmaps;
  • process is resource intensive, consider increasing JVM memory limits for Coldfusion.

OTHER TIPS

cfexecute should work.

Also consider cfx_image .. it is an excellent tag that inspired cfimage. I believe it also does vector images. There isn't much I haven't been able to do with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top