Monday, November 7, 2011

ImageMagick “-unsharp” parameters for web use?

Question

I am using the convert tool from the ImageMagick package to create the web versions of my photos. So far I have used something like convert -resize 1024x1024 for web versions and convert -resize 300x300 for thumbnails. However, many people seem to prefer adding a little bit of sharpening after resizing, and hence I have started to experiment with the -unsharp option.

We have an excellent answer on this site that explains the parameters of the "unsharp mask" tool and gives some recommendations of reasonable values for web use. However, one of my problems is that the unsharp mask option in ImageMagick seems to be somewhat different from the unsharp mask filter in Photoshop or GIMP.

Hence the question: What are the recommended parameters of the -unsharp option in ImageMagick for web use?

I am looking for "harmless" settings that I can safely use in bulk conversions, without any significant risk of creating visible artefacts (e.g., halos). Of course for optimal results I would have to manually fine-tune the settings for each photo, but I am interested in a quick solution that I can use for a large bunch of photos.

Right now I am using the following values (which may or may not correspond to something like radius = 0.5, amount = 50%, threshold = 2):

-unsharp 0.5x0.5+0.5+0.008

This seems to give reasonable results. The effect is very slight; it is barely visible in many cases, and it seems to be non-distracting in all photos that I have tried so far. Nevertheless, it helps a bit. But the question is: could I do better? What are your favourite values of these parameters?

Answer

Yes, from what I can gather, the settings are equivalent to those in "Photoshop" units.

The radius seems to be specified the same way.
For a radius less than 1 a sigma value the same as the radius is recommended.
An amount of 50% is specified as 0.5.
The threshold is specified as the fraction of the max color value, so 2/255 ~ 0.008.

The settings that I recommended in the answer are chosen to give a moderate sharpness that rarely causes oversharpening effects. The radius is what's generally recommended for screen display, so that should normally stay as it is.

You could push the amount a bit higher, but that might cause halo effects in images with high contrast edges. It's a matter of what you want to risk to get sharper images.

If you want the absolutely best result, batch processing won't do it. You will have to adjust the settings by hand for each image if you want the best possible result. Batch processing will always be a compromise.

No comments:

Post a Comment