rohan singh

software engineer. bicyclist & rock climber. craft beer addict.

Installing Pgmagick on OS X

pgmagick is a Python wrapper for for ImageMagick (or GraphicsMagick). I needed it for something I was trying to run yesterday, but the instructions for OS X seem to have gotten lost in the depths of the Internet.

I’m assuming you have a working Homebrew, Python, and pip. You’ll also need my Homebrew formula for Boost.

Once you’ve got that, it’s pretty straightforward:

$ brew install imagemagick --with-magick-plus-plus
$ brew install boost --with-thread-unsafe
$ pip install pgmagick

Building Boost takes a long time so don’t fret if you don’t see anything for a while. Try it out and it should work:

$ python
Python 2.7.2 (default, Oct 20 2011, 17:33:50) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pgmagick
>>> pgmagick.gminfo.library + ' ' + pgmagick.gminfo.version
'ImageMagick 6.x.x'

For extra credit, you should also be able to install the Python Imaging Library (PIL) as well:

$ pip install -f Imaging==1.1.7

This all worked for me on OS X 10.7 (Lion). Your mileage may vary on other versions.