How to batch insert text on photos?

2

1

I am on linux/Ubuntu and wondering what is the easiest way to add copyright text to a couple of jpeg images.

wbad

Posted 2012-05-07T15:30:58.803

Reputation: 427

Answers

4

ImageMagick can add text to images. It probably comes pre-installed on Ubuntu. An example of how to use it from their website:

  convert dragon.gif -gravity south \
          -stroke '#000C' -strokewidth 2 -annotate 0 'Faerie Dragon' \
          -stroke  none   -fill white    -annotate 0 'Faerie Dragon' \
          anno_outline.jpg

This puts the text at the bottom of dragon.gif, creating a new image anno_outline.jpg. There are lots of text effects that you can read about in the convert documentation.

If you are only doing a couple of images you don't really need a batch file, but if you are doing more, say a whole directory, you can just wrap the command in a for-do loop:

for FILE in *.jpg; do convert $FILE -gravity south -annotate 0 'copyright' new_$FILE; done

SigueSigueBen

Posted 2012-05-07T15:30:58.803

Reputation: 216

Great help. just 'do echo' does not work. You need to modify the batch command to something like this: for FILE in *.jpg; do convert $FILE -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 'copyright' -stroke none -fill white -annotate 0 'copyright' new_$FILE; done – wbad – 2012-05-14T19:50:54.427

I fixed the command, removing the echo. I'd put it in just to test that the script was correct and forgot to remove the echo before posting! – SigueSigueBen – 2012-05-14T20:13:58.293

i think it would be nice if you broke down what the command did, but I agree the effect however it works is pretty cool. – Evan Carroll – 2013-08-22T02:22:28.763

also that the bottom command is different from the top is slightly confusing. – Evan Carroll – 2013-08-22T02:23:30.390

2

Take a look at Image Magick and its convert command. It'll be something like:

convert -caption "(c) 2012 Mr. Photographer" original.jpg copyrighted.jpg

(Diving deeper into Image Magick docs will show ways to do this in bulk so that you can specify something like *.jpg for input files and the output files can be a variant on the original file name so that a.jpg becomes a-copyright.jpg, b.jpg -> b-copyright.jpg, etc)

Doug Harris

Posted 2012-05-07T15:30:58.803

Reputation: 23 578