Watermark all images

Recently I had to watermark around 500 images for an existing site.
Images are replaced with watermarked images!
I had problems with temporary/hidden images in the directory so the find statement contains a ! -name “.*” which negates hidden files on linux/macosx.

First script to find all jpg and JPG:

find . -iname "*.jpg" ! -name ".*" -type f -exec ./watermark.sh {} \;

This is the original image:

The script watermark.sh processes each image. Every image is watermarked with a text at the bottom and a almost invisible mask. The mask is an image with a white background and a light-gray logo (it doesn’t have to be transparant). This is the mask:

# Name:         watermark.sh
# Author: 	kdguntu@gmail.com
# Copyright: 	(c) 2011 GNU Copyright v3
# Function:     place watermark on input file
# Requires:	imagemagick (convert, composite)
# Arguments: 	$1 inputfile
# Place copyright text at the bottom
convert -size 120x15 xc:none -gravity center \
        -redoke black -redokewidth 2 -annotate 0 $COPYRIGHT \
        -background none -shadow 120x5+0+0 +repage \
        -redoke none -fill white  -annotate 0 $COPYRIGHT \
        $FILEIN  +swap -gravity south -geometry +0+5 \
        -composite $FILETMP
# Place mask image over picture (tiled)
composite -compose bumpmap  -tile $FILETILE \
          $FILETMP  $FILEOUT
rm -f $FILETMP
echo "$FILEIN is watermarked"

This is the watermarked image:

This entry was posted in bash, find, linux, macosx, ubuntu and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *