Imager from Image::Magick: Trial Run

I’m a hard-core Image::Magick user. I use it to automate graphics production for my board games and video games, and also use it to manipulate all of the graphics uploaded by our customers at The Game Crafter. One of my developers has been nagging me for years to switch to Imager, but Image::Magick has always worked for me, so I had no reason to switch.

I’m working on a new board game, and I just bought a new laptop, so I figured now was a good time to try out Imager, since I didn’t already have Image::Magick installed. Here’s what I’ve learned as of day one.

The Good

  • Imager renders the same images I was generating with Image::Magick in about 1/10th the time.
  • The API has better documentation than Image::Magick. For most of Image::Magick (the perl module) you have to go look at ImageMagick (the C library) to figure out how to do stuff, and not everything translates as easily as you might think.

The Bad

  • Imager wasn’t smart enough to pick up libraries (libpng, freetype, etc) from system environment variables such as DYLD_LIBRARY_PATH. Instead I had to perl Makefile.PL —incpath=/some/path —lib-path=/some/path
  • Imager doesn’t use exceptions. It uses this old school methodology of $img->do_something or die Imager->errstr;. However, that’s still better than Image::Magick’s return an error string from the function you’re calling and parse it to see if something bad happened.
  • Imager’s install process crapped out on libpng. It turns out I have too new a version (1.6, and Imager only supports 1.5). However, upon looking at Tony Cook’s git repo for Imager, I found that libpng 1.6 support is in, its just not released yet. So I cloned his repo and built Imager out of that.
  • Imager has no method for creating Ellipses/Ovals. The only way I could figure out how to do it was to draw a circle and then apply a transformation to squish it into the oval shape.

I know I’ve got more bad stuff in the list than good stuff, but the bad stuff isn’t all that bad, and one of the good things is totally excellent.

So far I’ve created images, composited other images over those images, added text, drawn basic polygons, and written all that to disk. By no means is this a complete test, but so far it looks like Imager may replace Image::Magick in my toolkit. If you’re looking for a solid imaging library for Perl, give Imager a shot.

[From my blog.]

2 Comments

Could you please open an Imager rt.cpan ticket with the output of:

perl Makefile.PL --verbose

with some details about the environment variables you had pointing at the headers and libraries?

Thanks.

WRT ellipses - it's mosly a case of me wanting them to be general at least to the point of rotating the axes (and lack of time.)

Leave a comment

About JT Smith

user-pic My little part in the greater Perl world.