7 Minute Miles

ImageMagick on Mac OS X


This site uses Gallery2 for the photos section and I recently set up something similar for a client. They had an additional request to include EPS, PDF, Photoshop and Illustrator files in the gallery, which I was sure it could handle. Unfortunately, the experience wasn’t so smooth.

Gallery2 supports several different graphics libraries, including GD, NetPBM and ImageMagick. I already had GD installed and supported by my webserver, so that was what I had been using. Each one has it’s own advantages and disadvantages, but GD does not support the file types I needed to add. After comparing the other two, I decided on installing ImageMagick (IM).

There are many ways to install IM, but there are several critical dependencies required to get EPS and PDF support, including GhostScript and several font files. Compiling from the source on the IM site is complicated by this and many of the pre-compiled binaries do not have the required pieces. After trying several of the pre-built binaries with little success, I turned to Darwinports.

I had used Fink in the past and never really liked the experience much. Darwinports serves a similar purpose: help compile and update unix-based applications via the command line while making dependencies easier to manage. The instructions for installing IM via Darwinports were a little confusing, as I knew I needed the variant for Ghostscript (gs), but the page didn’t say how to do that. It was easy:

Hecubus:/ dmk$ sudo port install imagemagick +gs

After quite a long while, the install finished and I had a working copy of IM located in /opt/local/bin. I pointed the Gallery2 IM module at that directory and it passed all of the configuration tests (identify, convert, composite). The installed version was 6.2.6 and it said it supported the following MIME types:

  • image/gif
  • image/jpeg
  • image/pjpeg
  • image/png
  • image/tiff
  • image/svg+xml
  • image/bmp
  • application/pdf
  • application/postscript
  • application/photoshop
  • image/x-photo-cd
  • image/tga
  • image/jpeg-cmyk
  • image/tiff-cmyk

Eveything was looking good, but my first few test files were hit and miss. Some files got perfect thumbnails created (PDF, BMP, some EPS), some got a blank white box (most PSDs), some got a box with the text name of the file (some EPS), while others just say “no thumbnail” and give a smarty error when clicked (only using the Siriux theme, though).

I turned on debug and looked at the commands being called via IM. No apparent errors, so I did some testing in the command line. I think I’ve narrowed it down to colorspace issues with EPS files and multiple layers with PSD files. If I add a -colorspace RGB flag to the EPS files, good jpeg previews are created. Similarly, if I add a -flatten flag to the PSD files, I get good jpeg previews on those too. I don’t know how to make those changes in the Gallery2 module, so I submitted a forum post to the Gallery2 community, but there hasn’t been much response.

So close, but still so far…DK

Originally published by DK on May 16, 2006 at 11:59 am in Technology


flourish icon