ImageMagick Tips and Tricks Part IV

Text, Labels and Captions

CONTENTS

Make an Image Label from Text


convert -size 200x -background Orange -border 1x1 -bordercolor Black -fill Purple label:"Metric Rat" label1.png


Make an Image Label from Text with Text always fitting on One Line


convert -size 200x50 -background White -border 1x1 -bordercolor Black -fill Black -gravity center label:"Use MIT AppInventor to make Android Apps" label2.png


Similar to the first example, but a defined height and width. ImageMagick will always try to force the text onto one line

Make a Text Image with Justified Text


convert -size 300 -font Ubuntu -border 10 -bordercolor White -define pango:justify=true pango:"$(cat ./lorem.txt)" pango_justify.gif


This uses pango, which should be installed by default, which provides more options, such as justify. Pango use the markdown language for the input of html tags in your text. The text is called in from a file. Adding a border helps here.

Make a transparent image with text, using 'caption' to fill the defined image area


convert -background transparent -fill Orange -font Ubuntu -size 320x140 -gravity center caption:'Metric Rat AI2 is a great place to learn about things you can do with AppInventor 2' captionBestFit.gif

You can see I use transparent for the background, and -gravity center to vertical align the text