Adding ‘Watermarks’ to many pictures (ImageMagic, and bash’s ‘for…do…done’)
(Information how to add exif-information to the filename is described in “Sometime in Summertime”)
So yesterday we had our big New Years Day Brunch at the restaurant. I brought my digital camera and took some photos. I took photos of the buffet and the guests, and as a last highlight, I ran a slide-show of the pictures they could watch when picking up their coats. So, in a rush of exitement, I promised them to have them printed on photopaper for them to pick up next time they come around. But given my shameless nature when it comes to advertizement, I wanted to stamp the pictures, so they would remember who filled them up for the first time this year. This is what I did:
stw@laptop:~/Bilder/2004-01-01 Brunch> for i in *; do convert -font /usr/X11R6/lib/X11/fonts/truetype/VANDIJKB.TTF -pointsize 96 -fill white -draw 'text 115,1775 "Waideles Brunch 2004"' -fill black -draw 'text 113,1773 "Waideles Brunch 2004"' $i Brunch$i; done
Long line, so let’s break it up:
for i in PATTERN; do COMMAND $i ; done
repeats everything between ‘do’ and ‘done’ for each file matching PATTERN. $1 is replaced by the actual filename.
is part of the ImageMagick suite. Everything you want to do with pictures can be done on the commandline with these programs.
tells convert to use the TrueType font defined in the file.
defines the size of the ‘writing on the wall’
write in white
-draw 'text 115,1775 "Waideles Brunch 2004"'
Draw the Text “…”, starting at x,y
-fill black -draw 'text 113,1773 "Waideles Brunch 2004"'
Same again in black, just 2 pixels shifted. That way the words are readable on dark and light background.
$i is the input-filename, The output is saved with ‘Brunch’ added in front of the original filename. Alltogether took less than five minutes, and even if you count the 30 minutes reading the docs and another 30 minutes writing this Tutorial, I would not have done it in 65 minutes on more than 70 pictures using a GUI-Application. And best: Now that I have figured out the line, I can repeat it in no time on as many pictures I ever want. “Waideles Brunch 2005” is already sceduled. I might invest in some photo-paper and hand them their picture right then and there