How to Position Text Bottom Right in ImageMagick?

Placing text in the bottom-right corner of an image using ImageMagick is a straightforward process achieved by combining the -gravity option with the -draw or -annotate settings. By setting the gravity to SouthEast, ImageMagick automatically aligns the text coordinates relative to the bottom-right corner. This article provides a quick, practical guide on how to structure the convert command, adjust font styles, and add padding to ensure your text looks perfectly placed.

The Core Command

To position text at the bottom-right corner, you must tell ImageMagick to shift its coordinate anchor point. The -gravity SouthEast option changes the origin point $(0,0)$ from the default top-left corner to the bottom-right corner.

Here is the standard syntax using the -annotate flag:

magick convert input.jpg -font Arial -pointsize 36 -fill white -gravity SouthEast -annotate +20+20 "Your Text Here" output.jpg

(Note: In ImageMagick v7 and later, the convert command is replaced by magick, though magick convert still works for backwards compatibility).

Breakdown of the Parameters

Alternative Method using -draw

You can achieve the exact same result using the -draw command instead of -annotate. The logic for gravity and offsets remains identical.

magick convert input.jpg -font Arial -pointsize 36 -fill white -gravity SouthEast -draw "text 20,20 'Your Text Here'" output.jpg

In this variation, "text 20,20 '...'" specifies the $X$ and $Y$ padding inside the quote block rather than using the plus signs.

Ensuring Readability Against Busy Backgrounds

If your image background is bright or complex, white text in the bottom right corner might become invisible. You can add a subtle background box or a text shadow to improve contrast.

Adding a Text Shadow

magick convert input.jpg -font Arial -pointsize 36 -gravity SouthEast -fill black -annotate +22+22 "Your Text Here" -fill white -annotate +20+20 "Your Text Here" output.jpg

By drawing the text twice—first in black with a slightly larger offset, and then in white with the normal offset—you create a crisp drop shadow effect.