Image by https://unsplash.com/@alexbdnr

Annotate pictures using imagemagick

Aymen Furter
1 min readMar 1, 2022

--

Recently I’ve started to publish sticker designs on redbubble. As I am after the “long-tail” items, I planned to generate hundreds of personalized stickers. You can apply this pattern for all kinds of use cases (for instance to generate stickers for each birthday).

First, we start by creating a template image. This image will be the background on top we add the text.

Next, we execute the following command to write text on top of the image (You may have to tweak the geometry parameter):

convert -font font.ttf  template.png -gravity center -background none -size 433x300! caption:mytext -geometry +10+170 -composite generated/mytext.png

Let’s assume we have a text file and want to generate an image for each line in the text file:

#!/bin/sh 
while read line
do
convert -font font.ttf template-new.png -gravity center -background none -size 433x300! caption:$line -geometry +10+170 -composite generated/$line.png
done < birtdays.txt

There you go!

--

--

Aymen Furter

I am a Cloud Solution Architect working for Microsoft. The views expressed on this site are mine alone and do not necessarily reflect the views of my employer.