I recently discovered that one of my most popular posts had been poached by another blog with out providing credit - images and all. I decided that it would be best to watermark my images to make it more difficult to rip off my content.
This procedure could also be done easily in GIMP, but it takes time to open up each image and then import or create the watermark text. Instead I created my desired watermark text in GIMP and saved it as a separate file called Watermark.png. This file has a transparent background, so only the text will show up when it's overlaid on another image.
For my demo I'm going to overlay the watermark on an image of Tux, the Linux mascot.
To create the watermark I'm going to use the composite command from the ImageMagick package. The structure of my command assumes that both the watermark and target images are in the same directory.
composite -dissolve 50% -gravity center -quality 100 Watermark.png Tux.jpg Tuxwm.jpg
This creates a new image called Tuxwm.jpg.
A little explanation of the command we performed. composite is the command to combine two images. The dissolve 50% switch tells ImageMagick to make the overlay image 50% transparent. The gravity center switch tells it to center the overlay image on the base image.
As you can see above, my watermark image is too large compared to the image of Tux. I'll need to shrink it in order for the result to look how I want. Now, I could go into GIMP and resize my watermark image, but ImageMagick provides an easy way to do this on the fly. With a slight modification to the above command I can scale down the watermark before it's overlaid.
composite -dissolve 50% -gravity center -quality 100 \( Watermark.png -resize 50% \) Tux.jpg Tuxwm.jpg
That looks a little bit better. Note that these commands have created a new image called Tuxwm.jpg. You can make the command overwrite the original image if you just pass the same file name at the end of the command like this.
composite -dissolve 50% -gravity center -quality 100 \( Watermark.png -resize 50% \) Tux.jpg Tux.jpg
This may seem a bit complicated to type this command to watermark a single image, but the nice thing is that it can be automated in a script so that you can watermark a whole directory of images at the same time. You can see that post here.
#
hi, is there any syntax available for -gravity aside from center? thanks in advance
#
Supported gravity options can be found with the following command:
You can also check out the ImageMagick documentation online. http://www.imagemagick.org/script/command-line-options.php#gravity
#
hello its been awhile since i last visit this post, thanks for the info. i am using southeast as gravity, kudos your script is very helpful, been using it eversince i stimble upon your blog.
#
*stumble lol
#
Dont know why but its working now, never mind
#
That's good because that error message has me stumped.
#
Unfortunately this does not work for me. In Ubuntu 9.1, I tried composite -gravity center image1.png image2.gif outputimage.jpg. However, I get " unable to open image `temp.png': No such file or directory @ blob.c/OpenBlob/2439.
#
I discovered an issue with watermarking TIFF images. I have added the -quality 100 switch to address this.
#
here's a script I wrote to do something similar for a #! forum member http://crunchbanglinux.org/forums/topic/3738/image-resizerwatermarker/ . Good tutorial 😉
#
iggykoopa - Thanks for the link. I'm working on a similar script. It's always interesting to see how someone else goes about doing things. I've been playing around with Zenity, but haven't really done much with it yet. Something I struggle with is deciding how much to hard code into the script vs. presenting options to the user. For myself, I like things hard coded in since it makes things quicker for me when I run the script, but I know that is not the most desirable way for many users.