Sunday, January 27, 2008

Insert a copy right label to a set of photos.

Most of us have photo galleries in the Internet. And we upload hundreds of thousands of photos to the Internet. I started to use this nice image manipulation tool named "Imagemagick" to insert a label (a copy right label or some thing) to a set of photos at a one go. since I felt it's very easy to do it by saving it as a script so I can just run it any time I want. Imagemagick is a very famous tool and it has various set of tools to manipulate images. You can check the man page for all the commands and syntaxes, or from web too. Since couple of people asked about this from me I thought of sharing it among all. Imagemagick is available for Mac, Unix and Windows platform too. But I'll stick to my favourite GNU/Linux way of doing it.

First check whether imagemagick is already installed in your system

In Debian based systems issue this command and see the result

#dpkg -l | grep imagemagick

If you don't have the package, install it using your favourite method. I used the apt.

#apt-get install imagemagick
I have collect all the steps and create the script below and run it inside the directory where the photos are located. Actually I reduced the image size to suite for upload, and reduce the quality a bit too. Then inserted the label to all the photos and finally open the photos in gthumb image viewer. First of all it copies all the photos in to a directory to preserve the originals. So you always have the original photos you've taken.


echo "Resize, Convert, prepare photos to publish for web.";
echo "==================================================";
ls *JPG;
mkdir temp
cp *JPG temp
cd temp
for PICME in `ls *JPG`; do convert $PICME -resize 800x600 -quality 80% $PICME; done
echo "Photos resized to 800 x 600";
for PICME in `ls *JPG`; do convert -pointsize 12 -fill Black -draw 'text 20 20 "Copyright 2007. M.D.D.Anuradha Mallikarachchi. All rights reserved."' $PICME $PICME; done
echo "Label inseted."
gthumb *

You can see the inserted label, at the top right of the photo. and it's very convenient for me, when I have to insert a label for set of photos at a one go.

Oh don't forget to make the script executable (chmod +x script) and put it in /usr/local/bin.

Hope this will be useful to some one. :-)