I've looked at pretty much every image manipulation extension to Perl that I could find on CPAN. For doing basic operations like opening an image, cropping it and saving it back, it seemed to be among the most straightforward of the bunch. Thus I started using it for my latest project.
I was at first disappointed to discover that I couldn't do something I somehow assumed there would be a function for (I needed to replace one color in an image with another) and almost gave up on it, until I discovered Imager::Transform2().
It's rather complex to understand at first, and it may take a day or so to figure out, but wow... the things you can do with it once you learn how it works. You can write simple or complex expressions that are applied to every pixel in an image... but unlike other interfaces where you fetch one pixel at a time, do something with it in perl, and then put it back (which can be pretty slow for a large image), it internally compiles your expression into virtual machine code which executes as speed comparable with custom C routines. However, you don't need to write a whole XS module and compile it and try to distribute it with your project. It's just a line of perl code with the expression in it that you can dynamically build in perl if necessary. Documentation about it could be a bit clearer in places.
Imager::Transform2 is amazing to me and will allow me to do most things I could need if builtin functions don't already exist.
Other than that, the file support could be beefed up some to support more formats, which I guess would be fairly straightforward. Also PNG files written seem to be larger than the originals even if you just read it in and write it out, so some compression setting is probably needed there by default.
After messing with Image Magick in frustration over the years, I discovered Imager, and found it to be the "just right" solution for manipulating images in perl. Clean interface, great feature set. Documentation is good, too. Congrats to all who contributed.
I use it with windows XP and ActiveState perl. Version 0.55 does support JPEG files. I use it to create pie charts (the only format available) and they always turn out great looking. Its also very fast. My charting requires pie charts for over 30 items and it takes less then one minute to create the charts and display the results over the web.
Installing and using this was a lot easier for me than for other Perl image manipulation/generation modules. I found I was able to install and compile without a single additional dependency, but your results might vary. The cookbook and other documentation is very complete.
It did everything I needed. I went from finding it on CPAN to installing it to having a working example for my client in about 4 hours.
I had originally reviewed Imager in 2003. It was wonderful then, but it has come a long way. Particularily, I am now able to compile it on Windows and write fast (and simple) XS extensions for it.
Addi has put a lot of work into this impressive package, but the current maintainer, Tony Cook, has done miracles.
Imager has become a great replacement for GD and ImageMagick and feels much better integrated into Perl, the language, than either of them.
The original review is retained below:
Imager is the graphics module I had been waiting for.
It's easy to use and has a great interface. It's more powerful than ImageMagick and GD. Plus, it's fast and portable.
I've been using Imager in quite a few of my modules directly (Math::Project3D::Plot, etc.) or indirectly by suggesting the user go with it for visualization (Physics::Particles, Physics::Springs, Physics::Springs::Friction). I originally used GD and ImageMagick, but both of those modules/libraries had certain drawbacks. Imager was the natural replacement.
This module has the potential of being a reason to use the Perl language.
2006-08-04: Those restricted to Windows boxes be warned: the both standard AS and bribes PPD of this module supports no image formats other than : bmp rgb w32 pnm tga ifs raw. No JPEG, PNG or even GIF support. That means no loading or writing of the files you probably want to work with.
Imager mixes very nice high-level abstraction with the ability to get at the nitty gritty easily. While using Imager to write an image comparison module I quickly realized that itterating over every pixel was extremely slow. After looking at the documentation a bit, I discovered methods which appear to be custom designed for low level (fast) access without the overhead of per-pixel object instantiation. getsamples() and getscanline() sped up the comparison module immensly. Even if I hadn't found those two methods, there's a very nice CountColor.xs file which is a relatively straightforward introduction to programming Imager using xs, which could get you much the same results with just a little bit more effort. There are also some examples of using Inline::C (though I didn't look as closely at those.)
I guess what I'm getting at is that like Perl, Imager makes the easy things easy and the hard things possible. For that, Tony, I owe you a beer.
The documentation, although existent, is quite disorganized. By this I mean it is difficult and not always intuitive where the documentation for a specific and known feature can be found. There is not enough examples of how certain features work (like map() for example.) There are no tutorials that I can find and no mailing list. The homepage links in the PODs are broken. This lack of coherent documentation is my primary beef. Were it not for this my rating would be at least 4/5.
Other than this, the module works well and is even faster than GD in many instances. GD however is much easier to learn, again due to the superior documentation.
Imager is a great module, particularly compared to GD and ImageMagick. It's easy to install, beautifully documented and performs great. If you need to do any work on images in Perl then you can stop looking now. You've found your solution.
Imager is like Photoshop in a module. It supports most things one could ever want, from really simple drawing to advanced transformations and a very neat plug-in architecture for writing image filters. It's also very simple to use, supports the most common formats and has great support for fonts and drawing text. As an added bonus, it works on Win32 and can use GDI on that for drawing text (good quality).
I recommend Imager from the bottom of my heart to all the users who wants to do image manipulation and/or image generation.