How to Specify Font in ImageMagick Convert?

This article provides a quick overview and practical guide on how to specify a custom font type when adding text to an image using the ImageMagick convert command. You will learn the exact syntax required, how to list the available fonts on your system, and how to troubleshoot common path issues to ensure your text renders correctly.

The Basic Syntax

To specify a font type in ImageMagick, you use the -font setting followed by the font name or the direct path to the font file. This setting must be placed before the -annotate or -draw commands where the text is actually defined.

Here is the standard command structure:

magick convert input.jpg -font Arial -pointsize 36 -fill white -annotate +50+50 "Hello World" output.jpg

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

Specifying Fonts by Name vs. TrueType Path

You can define the font in two distinct ways depending on whether the font is registered with ImageMagick or sitting in a specific directory.

-font Helvetica-Bold
-font "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"

How to Find Available Font Names

If you aren’t sure what names ImageMagick recognizes on your current machine, you can generate a complete list of configured fonts by running the following command in your terminal:

magick -list font

This will output a list of font names, families, and glyph paths that you can safely use directly with the -font flag without needing to look up their exact directory paths.