crazed monkey

Ian Stevens’ weblog

RSS

Python bindings for ImageMagick’s MagickWand API

I’ve been spending some of my spare time recently putting together some Python bindings for ImageMagick’s MagickWand API. While most bindings I’ve seen just look like generated ctypes code from C header files, these bindings are more object-oriented, completely hiding the MagickWand methods. While this is still in the early stages, it’s workable in a way which I hope is expected and unsurprising:

from pythonmagick.image import Image
from pythonmagick.color import BLUE
i = Image('foo.jpg')
i.format = 'PNG'
i.rotate(45, BLUE)
i.save('flip.png')

The above reads in a JPEG image, reformats to PNG and rotates by 45 degrees with a background colour of blue. The image is then saved to a new file.

This may look a lot like PIL code, so why not use it instead of ImageMagick? ImageMagick covers a much wider range of image formats than PIL, and supports better algorithms for image resizing.

Check out the bindings by installing them with easy_install:

easy_install http://svn2.assembla.com/svn/pythonmagickwand/trunk/

On a side note, I’m quite impressed with Assembla, the site which I’m using for my SVN and Trac repo. It’s about as good as something I would deploy myself, but with much less hassle. Honestly, these days there’s less and less reason for me to spend hours setting up stuff myself, and that’s a great thing.

Posted on March 14th, 2008 in python - 2 Comments »

Nana Aba Duncan TV hosting reel

My wonderfully talented girlfriend, Nana Aba Duncan, just posted her new TV hosting reel on YouTube. Her bright and fun personality really comes through in this video. Yes, she is that energetic in real life.

If you’ve caught the Nana fever and the only solution is more Nana, be sure to also check out her DiverCity podcasts on BlogTO.

Posted on February 29th, 2008 in television - 1 Comment »

What I really want: A command-line preflight tool for PDFs

Creating PDFs is difficult. Creating PDFs for print is even more difficult. Reportlab does a great job, but it defaults to RGB in most cases. This necessitates some tweaking of both Reportlab code and the code using Reportlab. Testing the result is difficult, mostly because I don’t know of any command-line tools to do preflight testing for RGB and CMYK elements.

What I need is a command-line tool to do some basic PDF preflighting (eg. non-CMYK elements, non-embedded fonts, images below 300dpi, characters which may cause difficulties in printing, etc.). Is that so much to ask? When the PDF spec is 1300 pages long, it is. Still, don’t think I won’t try and take a stab at it.

Posted on February 27th, 2008 in programming - No Comments »

Bad transit map redirect due to hosting upgrade

On Monday my hosting service moved their servers. Ever since then requests on my site for URLs not ending in a backslash forward to crazedmonkey.nfshost.com. This means that if you access my transit map without including the backslash, the map will refuse to load because of inconsistencies with the Google Maps API key. I’ve opened a related ticket with my hosting service and hopefully they’ll fix the issue. In the meantime, please use the URL which works.

Tags:
  • none

Posted on September 13th, 2007 in transitmap - 3 Comments »

Avoid the honey in coffee shops

This morning after having bought my coffee, I went to grab the honey from the self-serve area. Noticing it was missing, I checked above the espresso machine to see if it was there. As it wasn’t, I asked someone for it and they went to get a fresh one. Upon his return, he told me that they were now keeping the honey behind the counter as “people were drinking it.” I wasn’t so much disgusted as I was upset at being told that fact now after months of adding saliva-laden honey to my coffee. Sometimes honesty isn’t the best policy.

Posted on September 12th, 2007 in culture - 3 Comments »