How to use ImageMagick convert unsharp mask?

This article provides a quick overview and practical guide on how to use the ImageMagick convert command to apply an unsharp mask, a powerful digital image processing technique used to enhance sharpness and clarity. You will learn the specific syntax of the -unsharp operator, understand how its various numerical parameters control the sharpening effect, and see concrete examples to achieve professional results on your images.

Sharpening an image with ImageMagick relies on the -unsharp option, which actually uses a blurred (or “unsharp”) negative image to create a mask, adding contrast back into the original image’s edges. The command follows a standard structure where you pass a specific sequence of numbers to fine-tune the radius, sigma, gain, and threshold of the effect.

The basic syntax for the command looks like this:

magick convert input.jpg -unsharp radiusxsigma+gain+threshold output.jpg

Note: If you are using ImageMagick v7 or later, the standard command is simply magick instead of magick convert, but the parameters for the unsharp mask remain exactly the same.

To get the best results, it helps to understand what each of these four parameters controls:

Here are a few practical examples demonstrating how to combine these settings for different photography needs:

Standard Web Sharpening

For general images being prepared for a website, you want a subtle but noticeable boost in clarity without creating harsh artifacts. magick convert photo.jpg -unsharp 0x1+1.0+0.05 sharp_photo.jpg

Strong Edge Sharpening

If you are working with slightly blurry text, architectural photography, or images with distinct lines, you can increase the gain. magick convert document.png -unsharp 0x1.2+2.0+0.02 sharp_document.png

Soft/Fine Detail Sharpening

For portraits or nature shots where you want to preserve soft gradients but sharpen fine details like hair or feathers, use a smaller sigma and lower gain. magick convert portrait.jpg -unsharp 0x0.5+0.8+0.1 sharp_portrait.jpg

When experimenting with ImageMagick sharpening, it is always best practice to test different sigma and gain combinations on a duplicate image until you find the perfect balance for your specific resolution and subject matter.