image magick

When drafting my travel notes, I needs to modify lots of photos I took during the trip. Thus I started to dig again with ImageMagick . Lucky, I found this blog from Amy Tabb that achieves exactly what I am proposing to do.

Here is a example code snippet of adding watermark to an image via imagemagick.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# step 0 - get all available font list
convert -list font > fonts.txt

# step 1 - generate transparent stamp
convert xc:transparent \
  -font Smiley-Sans-Oblique \
  -size 640x200 -pointsize 144 \
  -fill black        -annotate +48+128 '©E. Yang' \
  -fill white        -annotate +52+132 '©E. Yang' \
  -fill transparent  -annotate +50+130 '©E. Yang' \
  stamp.png


# step 2 - generate composite mask
convert xc:black \
  -font Smiley-Sans-Oblique \
  -size 640x200 -pointsize 144 \
  -fill white   -annotate +48+128 '©E. Yang' \
  -fill white   -annotate +52+132 '©E. Yang' \
  -fill black   -annotate +50+130 '©E. Yang' \
  mask.jpg

# step 3 - merge things together as watermark
composite -compose CopyOpacity mask.jpg stamp.png watermark.png

Reference