http://www.perlmonks.org?node_id=716747

ggvaidya has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow monks,

On my current project, we need to be able to accept a number of image formats from our users. The easiest way to achieve this is by using Image::Magick, which handles a very large number of input formats, and using it to convert the input file into a standard image format, such as LosslessJPEG.

The Image::Magick module is a very straightforward wrapper around the ImageMagick library, because of which it has lots of C-isms (not having thrown exceptions, methods returning complicated numbered error messages, and so on) as well as ImageMagick's own limitations (returning descriptive names instead of standard MIME types, for instance).

I've got two questions:

  1. Is ImageMagick still the best library for image conversion on Windows in Perl? Are there better libraries out there which I haven't heard about?
  2. Since I am going to be collating all my Image::Magick fixes into one module anyway, does it make sense to package this into an Image::Magick::Image module, which will encapsulate a single ImageMagick image? This module can then provide exceptions on input/output methods, make it easier to access image attributes, and generally fix up ImageMagick's more irritating warts. Do you think there is a need for such a module? Would it be worth the effort of packaging it for CPAN?

Thanks for your help!

Update: Removed reference to Image::Magick being procedural; this was just plain wrong. Thanks, mirod!

Update Oct 24, 2008: Matt Trout recommended that I use Image::Magick::Object (or my own variant on his suggestion, Image::Magick::Wrapper) as an overall package name. Individual images can then be wrapped by Image::Magick::Wrapper::Image, and we could wrap other IM objects as well - a path could be Image::Magick::Wrapper::Path, for instance. Much easier to extend functionality that way. My only worry is that names will get overly complicated. Any comments/suggestions?

Update Oct 24, 2008: It's going to take a couple of weeks at least to get my very small codebase released to CPAN. I've only got about three operations wrapped so far: Read(), Write(), and converting some of Image::Magick's inbuilt format names to standard MIME types. If anybody else feels like going ahead with this, please do! Otherwise, I'll make good my promise and make sure I get a very early release sometime in November. Once it's out under a good license, interested parties can get cracking on wrapping all of Image::Magick.