How to Add Text Drop Shadow in ImageMagick?

Adding a drop shadow to text using the ImageMagick convert command involves creating a text layer, duplicating it to create a shadow, blurring and shifting that shadow layer, and finally merging the text over the shadow onto a background. This guide walks you through the precise command-line structures, parameters, and syntax required to achieve a clean, professional text shadow effect.

The Basic Command Structure

To create a text drop shadow, you typically use the magick convert command (or simply magick in newer versions) alongside settings like -shadow and -composite.

Here is the standard command template:

convert -size 600x200 xc:white -font Arial -pointsize 48 \
\( -background none -fill black label:"Shadow Text" -shadow 60x5+4+4 \) \
\( -background none -fill blue label:"Shadow Text" \) \
-geometry +30+30 -composite output.png

Breaking Down the Parameters

Understanding how each flag modifies the shadow allows you to customize the blur, opacity, and positioning to fit your design needs.

Creating an Advanced Drop Shadow with Custom Color

If you want the shadow to have a specific color tone rather than standard black, you can use the -matrix operator or change the background properties of the shadow layer.

convert -size 600x200 xc:lightblue -font Georgia -pointsize 50 \
\( -background none -fill Roboto label:"Graphic Design" -shadow 80x4+5+5 \) \
\( -background none -fill white label:"Graphic Design" \) \
-layers merge +repage output_custom.png

Using -layers merge instead of -composite is highly efficient when handling multiple overlapping layers, as it automatically respects the virtual canvases created by the -shadow effect without requiring manual geometry shifting.