Watermarking images
You may have a collection of photos that you want to exhibit online or forward to third parties. If you want to make sure that the images cannot be claimed by others, you can simply add a watermark. However, this is a lot of work manually, especially with large numbers, so let's see how to do this via a script.
ImageMagick
ImageMagick is a tool to create, edit and convert images. So there are a lot of possibilities, but in this blog post I will limit myself to adding a watermark to a collection of images. The tool can be downloaded for free from the official website.
There are four important commands for what we want to achieve: -fill
, -draw
, -pointsize
and -annotate
.
-fill
: specify the color that ImageMagick should work with to draw or write something – this can be a name, but also a hexadecimal value or an RGB value;-draw
: with this you draw a certain shape on top of the image (such as rectangles or circles);-pointsize
: specify the font size;-annotate
: the easiest way to add text on an image.
Just throw these commands together and we get the following command. Note that the value #ffffff33
is used so the background will be somewhat transparent.
Of course, our collection of images doesn't consist of photos of all the same dimensions – for starters, some are portrait, some are landscape. The PowerShell function below calculates where the watermark should be positioned, so that it always ends up at the bottom of the image. Feel free to play with the colors and the positions yourself to see the effect.
Now simply run this function for your images and they will all be watermarked in no time.