How to Change Text Color in ImageMagick?

This article provides a quick overview and practical guide on how to change the text color when annotating images using the ImageMagick convert command. You will learn the exact syntax required, how to use the -fill option to specify colors, and how to combine it with other text-formatting settings to customize your image overlays.

When adding text to an image using ImageMagick’s convert command, the -fill option is the primary setting used to define the text color. By placing -fill before your text-rendering commands (such as -draw or -annotate), you tell ImageMagick which color to apply to the font characters.

The Basic Syntax

To change the text color, you specify the color immediately after the -fill flag. ImageMagick accepts standard color names (like blue, red, or white), hex codes, and RGB/RGBA values.

Here is the standard command structure:

magick convert input.jpg -font Arial -pointsize 36 -fill red -annotate +50+50 "Your Text Here" output.jpg

(Note: If you are using ImageMagick v7 or newer, the command is simply magick, though magick convert still works for backwards compatibility).

Common Color Formats

ImageMagick is highly flexible with how you define colors. You can choose the format that best fits your workflow:

Combining Color with Other Text Settings

To make your colored text stand out against busy backgrounds, you can pair the -fill option with the -stroke and -strokewidth options to create a text outline.

magick convert input.jpg -font Georgia -pointsize 48 -fill yellow -stroke black -strokewidth 2 -annotate +100+100 "Outlined Text" output.jpg

In this example, the interior of the text is filled with yellow, while a 2-pixel black border wraps around each letter, ensuring the text remains legible regardless of the image background.