Fanning Software Consulting

Cannot Spawn ImageMagick convert Command

Facebook Twitter RSS Google+

QUESTION: Your Coyote Library is terrific. Love it! I just have one problem with it. I've installed ImageMagick and Ghostscript on my Macintosh computer as you recommend, and when I run the cgHasImageMagick function it returns true, but every time I go to make a raster file, I get this kind of error message.

   convert: bad parameters to zlib `/var/tmp/magick-68482-VTKI5KtApHb1' 
       @ error/png.c/MagickPNGErrorHandler/1804.
   convert: corrupt image `/var/tmp/magick-68482-VTKI5KtApHb1' 
      @ error/png.c/ReadPNGImage/4074.
   convert: Postscript delegate failed `/Users/blesht/': 
      No such file or directory @ error/ps.c/ReadPSImage/837.
   convert: no images defined `PNG24:/Users/blesht/histtest.png' 
      @ error/convert.c/ConvertImageCommand/3147.

Oddly, the problem is not with the ImageMagick command your Coyote Library routines generate, because if I execute that command at the Unix command prompt, it executes perfectly. Rather I can't, for some unknown reason, spawn that command from within IDL. Do you have any idea what is going on?

ANSWER: Yes, thanks to the tireless and dedicated detective work of Barry Lesht I think we finally know what the problem is!

The problem, in a nutshell, is that IDL is distributed with a version of zlib (verison 1.2.3 in IDL 8.2.3) that is incompatible with the version distributed with ImageMagick (version 1.2.8 in the latest version of ImageMagick). When an ImageMagick command is spawned from within IDL, it uses the wrong version of zlib to help with the PostScript conversion process. These are the errors that result.

The solution, according to Barry (I do not have a Macintosh computer to test this on), is to find the version of zlib in IDL (his was in the /Applications/exelis/idl/bin/bin.darwin.x86-64 directory) and to replace that version with the ImageMagick compatible version. Then he updated the link (libz.a.dylib) to point to zlib version 1.2.8 instead of to version 1.2.3. When he restarted IDL, he was now able to spawn the ImageMagick command from within IDL. All is right again with the world!

Version of IDL used to prepare this article: IDL 8.2.3.

Written: 28 February 2014