Do more, be better

Picture this

by John on 29 September 2011, filed under Wired in

Last week I needed to implement some image resizing and optimising functionality to Luumin, something for handling images like avatars and previewing content. Having used ImageMagick for the last several years by calling the executable directly, it seemed like an opportune time to see what other libraries were available and what ones were able to be baked directly into PHP. I wanted to look at how fast the various options were, how much memory they used and most importantly what the image quality was like.

There are currently three image libraries that are documented on the PHP site. GD2, which is typically bundled with PHP; IMagick – an object oriented interface for the various ImageMagick libraries and GMagick – a interface similar to the IMagick library but uses GraphicsMagick an ImageMagick alternative.

Looking at the available libraries, I rather quickly dismissed the native GD implementation. This was primarily due to limited list of supported image formats. When allowing users to upload images, you want to make sure that you can support multiple formats. Both ImageMagick and GraphicsMagick support a wealth of image formats, many of which even I have not heard of.

The real test was then to see what library performed best. To do this I wrote a simple script to take an image, rotate it, scale it and repeat. I was primarily interested in image quality and speed. In the end both libraries performed well in terms of speed. ImageMagick, however, won hand down in terms of image quality. I noticed significant “jaggies” when rotating and scaling in GraphicsMagick whereas ImageMagic produced clean, high quality images.

This testing was far from conclusive, and I do wonder if there alternatives, or if there were problems with my GraphicsMagick installation. I’d be very interested to hear other peoples observations and thoughts?

Tags: , , , ,

Something you want to say?

If you'd like to drop us a line about this blog post - or about anything at all - fill in the form below. This isn't a public comments board, so all correspondence will remain private (unless we both agree otherwise!)