We want to have nice pictures in our posts. So do You. Good composition, colors and focus are by all means necessary. But there’s at least one more step between picture in your camera and picture on your web – resizing. Either on your computer in your own image editor, or on the server using image processor designed for that purpose, or on both.
In this article we will look at the quality of the server-side processing of the pictures when they are being resized. There are two tools for image handling running under php. First is build-in php image processor called GD. Second tool is ImageMagick which needs to be additionally installed on the server.
Focus on Details
If you want really nice pictures, details matter. Details are the magic that makes the picture look extraordinary good. We examined how GD and ImageMagick behave when it comes to details. With GD we don’t have many ways how to affect the result, but with ImageMagick we have the choice of filters and sharpening options. Look at the following portrait and notice the difference. You can see that the GD picture looks somehow blurry while the ImageMagick looks more sharp and preserves details.
Details in the following example are even more disturbing in the case of GD. You can clearly see not even the blurriness, but also ugly artifacts around the windows – the set of lines formed by windows is really distracted in the GD case.
As you probably already have noticed, the ImageMagick files are significantly bigger than the files produced by GD. This is the price we are paying for keeping the details. In comparison, Photoshop has slightly smaller files than ImageMagick.
The last example might be not so obvious. We resized the original picture only to 50% of it’s size and cropped part of the face:
If you look very carefully you can see the small differences around eyebrows, eyelashes and in the center of the eye.
Another feature provided by ImageMagick is sharpening, while GD does not offer this option. Sharpening is applied during the resizing process, by default no sharpening is used. We already noticed that even this option is turned off, the pictures processed by ImageMagick look more sharp then the ones from GD. Here we offer a closer look at the effect of different sharpening values:
ImageMagick, no sharpening (=1)
We can see that slight sharpening (0.9) as used in the top left picture might be sometimes handy, but care should be taken to not use this parameter in extreme values as ugly artifacts come along this process – see the area around eyes or hair in the bottom right picture.
We care about how our pictures look, and so should You. In this comparison we showed that ImageMagick behaves much better when it comes to details and we think that ImageMagick should be used instead of GD whenever possible. We are willing to pay the price of bigger files in favor or preserving details.
In this comparison we used the compression quality equal to 100% to not get any form of distraction from the compression algorithms. The filter used in ImageMagick for the resize was the Lanczos filter.