akikorhonen
» Menu
» My latest @ Flickr
Aurora Borealis - Tampere, Finland 2013-03-17 20130304-1705-DSC_3810 [Browse]
» My latest @ YouTube
» Links
 
/home/ak/projects/programming/watermarking-batch-scripts

Watermarking Scripts


If you need to add a watermark to a bunch of photos, these little scripts come in handy. You"ll need a command line tool from ImageMagick called composite.

You"ll need a watermark image somewhere, eg. C:\watermark.png or ~/watermark.png (/home/user/watermark.png) for Linux. Change the full path to the appropriate place if needed. You can also change the prefix (w_ by default) for the watermarked images. The script goes through all the JPG files in the directory that is given as a parameter and adds the watermark image to the location given and with an opacity of 45%.

For Windows, put it in a file like add_watermark.bat.
Usage:
add_watermark.bat "C:\location_to_photos\"

@echo off

set wm_image=C:\watermark.png
set out_prefix=w_
set wm_location=southeast

set input_directory=%1
cd /d %input_directory%

for /f %%a in ("dir /b *.jpg") do call :ADDSTAMP %%a
goto :eof

:ADDSTAMP
set file=%1
echo Making watermarked image %out_prefix%%file% from %file%
composite -dissolve 45 -gravity %wm_location% %wm_image% %file% %out_prefix%%file%

For Linux, put it in a file like add_watermark.sh.
Usage:
./add_watermark.sh /home/user/location_to_photos/

#!/bin/sh

wm_image=~/watermark.png
out_prefix=w_
wm_location=southeast

input_directory=$1
cd $input_directory

for file in *.jpg
do
 echo Making watermarked image $out_prefix$file from $file
 composite -dissolve 45 -gravity $wm_location $wm_image $file $out_prefix$file
done

The output on both should be something like this:
Making watermarked image w_image1.jpg from image1.jpg
Making watermarked image w_image2.jpg from image2.jpg

Usage on your own risk, I don"t provide any support for these. I just made them for my own use and they work for me.