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. :-)


enTRpy said...

Great tutorial! Thanks for posting :)

Abdul Haleem said...

Really Nice Anuradha, Clear explanation with an exmple.

Thank you

Anonymous said...

Good for people to know.

Anonymous said...

Great Work.. :D

Anonymous said...

I will not concur on it. I over nice post. Especially the title attracted me to be familiar with the whole story.

Anonymous said...

Amiable brief and this fill someone in on helped me alot in my college assignement. Thanks you for your information.

Anonymous said...

Here is my version, taking care of the common image types like jpg,png,gif,tif and bmp.

In a bash script, it would look like this:


if [[ ! -e $copydir ]] ; then mkdir $copydir ; fi
pics=$(ls | egrep *.+\([jJ][pP]+\([eE][gG]\|[gG]\)\|[pP][nN][gG]\|[gG][iI][fF]\|[tT][iI]+\([fF]\|[fF][fF]\)\|[bB][mM][pP]\))

printf "found pictures : $pics\n"

for pic in $pics; do {
cp $pic $copydir
echo "resizing $newpic"
convert $newpic -resize 800x600 -quality 80% $newpic;
echo "labeling $newpic"
convert -pointsize 12 -fill Black -draw 'text 20 20 "©BLAH 2010. All Rights Reserved."' $newpic $newpic;

#showing the last one
eog $newpic &


Anonymous said...

Thanks for the info