views:

1059

answers:

3

Hello everyone,

Coldfusion has great cfimage tag that works perfectly. However, it not allows vector formats to be manupulated. This makes me 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 tried the following:

cfexecute with arguments to run command-line 'convert' command. Coldfusion page gives nothing - just empty page. Images are not got 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.

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

A: 

cfexecute should work.

Henry
Thanks, it really 'should' but doesnt :) I tried to write absolute path to IM executables, relative path, with forward slashes, backslashes, doubleslashes... It just not running. Using Vista, CF8, Apache.
Rodion Bykov
Do you include a timeout? If you don't, cfexecute returns immediately, even before the command is finished.
Tomalak
Hi,thank you for suggestion, it worked, but in combination with other things (please check I answered below).
Rodion Bykov
A: 

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.

Jas Panesar
Thanks, but I decided to go with ImageMagick and make it work. Please check my answer below.
Rodion Bykov
+2  A: 

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(filename2)#"" ""#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.
Rodion Bykov
maybe you should answer yourself, and Click it as the best answer. You'll earn yourself a badge as well. :)
Henry