subtlemark: Watermarking Images

A quick look at how to automate the process of adding subtle watermarks to images.

1. Configuring Fonts for ImageMagick

ImageMagick uses fonts-conf to detect and use fonts. As such, the default configuration gives many fonts to chose from. To list available fonts, use identify -list font | grep "Font:"

Since I want my watermark as subtle as possible, I'll use a tiny font, silkscreen, which is only 5 pixels high. To install the font (for a single user), unpack the ttf-files to ~/.fonts/

ImageMagick should now be able to find the font.


If for some reason the ImageMagick doesn't properly detect the font, you can use a script (imagick_type_gen) to generate an ImageMagick font configuration file. Here is how:

The newly generatedfile ~/.magick/type.xml should contain the entry:

  <type
     format="ttf"
     name="Silkscreen"keyfunc-output-overlay.png
     fullname="Silkscreen"
     family="Silkscreen"
     glyphs="/home/okami/.fonts/slkscr.ttf"
     />
        ]]>      

3. Key Functionality

Extending image with watermark label

The following snippet shows how the convert tool can be used to extend an image with a text label:

Input

(Click to enlarge)
Output

Overlaying watermark on top of image

Changing the image size can mess up the perfect screen resolution of an image. Here is a different snippet, that draws a rectangle on top of the image, and the text on top of that again.

Input

(Click to enlarge)
Output

4. Bash script

I got carried away with adding features to the script ^_^

Example use:
Add a watermark overlay to an image. The caption should say "SwarmingLogic", be on the top left, with text color #243A, transparent background, and use the font Silkscreen with point size 8.


The final script: