2010-10-01

FreeBSD - How to watermark image or picture using command line

Watermark is a technique to impose image or words using light shades. Digital watermark on image is use for the purpose of copyrights, comments or notices. Watermark image can be accomplish using tools from Image Magick suite of programs.

Firstly, install the ImageMagick port using portmanager :
portmanager graphics/ImageMagick -l


Then proceed the below steps to watermark the image :
  1. Create a .png image file with the wordings for water marking. Spend some time think about the wordings color & image background, how it blends into the original image. In this case, name the image "watermark.png".
  2. For backup purpose, duplicate original pictures/images.
  3. Execute the following to watermark the picture :
    composite -dissolve 80 -gravity southeast watermark.png image-before.png image-after.png

    where :
    -dissolve ==> shade brightness of watermark. If the original image is darker, use 80% or above.
    -gravity ==> location of the watermark to be paste onto the picture. E.g. north, south, east, west, northwest, southeast, blah blah blah.
  4. Repeat the previous step to get suitable angel & shades of watermark.
  5. To water mark a batch of images, create a bash script out of the following :
    #!/usr/local/bin/bash
    # this is iterate all the images prefix with name "images" and ends with .png
    # in the current directory and put it into the directory of "watermarked"
    mkdir watermarked;
    for image in $(ls images*.png);
    do
        echo "Watermarking $image ...";
        composite -dissolve 80 -gravity southeast watermark.png $image watermarked/$image;
    done

Farvel !!!

No comments: