ImageMagick

ImageMagick is a cool toolkit; not only it’s a complete set of command-line applications, ported to Windows, Mac and Linux, supporting hundreds of different image formats, it’s also a C++ library that you can use in your own applications!

On Mac OS X, I installed it via MacPorts using the all-time classic:

sudo port install ImageMagick

Then I created a C++ command-line application with Xcode, set the header and library paths in the target properties (/opt/local/include/ImageMagick and /opt/local/lib in this case) and I was ready to code. The API documentation and the tutorial give some hints, and using those examples I’ve cooked a quick image transformation utility to play with:

[source:c]

include

using Magick::Image; using Magick::Geometry; using Magick::Blob;

int main (int argc, char * const argv[]) { Blob blob;

Image png;
png.read("pic.png");
png.write(&blob);
Image jpg(blob);
jpg.magick("jpg");
jpg.zoom(Geometry(100, 200));
jpg.write("newpic.jpg");
Image tiff(blob);
tiff.magick("tiff");
tiff.zoom(Geometry(3000, 84000));
tiff.write("newpic.tiff");
Image gif(blob);
png.magick("pdf");
png.write("newpic.pdf");
return 0;

} [/source]

Interesting stuff indeed! The API provides a complete set of “Photoshop-like” operations on images, which I plan to study further in the near future.