Image by

Annotate pictures using imagemagick

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:

while read line
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!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aymen Furter

Aymen Furter

DevOps – Linux — Kubernetes –Azure — Java — JS — Apache Camel