Easy ways to add watermarks to images and videos in Linux

Mostly notes to myself :-)

Here is a quick way to add watermarks to photos and videos. All Linux command line based - so perfect if you've got a lot of images you want to manipulate.

Here is a delightful photo I've taken of a bee covered in pollen. I want to add a little copyright notice to it in order to discourage people using it without permission.

Bee covered in pollen

This command uses imagemagick's "annotate" option.

convert bee.jpg -gravity SouthEast -pointsize 16 -font TinyUnicode-Medium -fill "#fffdc3" -annotate +10+10 "(C) @edent" bee1.jpg

It produces this:

Bee covered in pollen with pixel watermark

As you can see, a small watermark in the bottom right - specified using -gravity SouthEast. I've chosen a yellow colour for the font - in homage to the EURion anti-counterfeiting symbols.

The -annotate command contains the distance in pixels from the edges

For small text, I favour a Pixel Font like TinyUnicode - but feel free to choose one which suits your needs.

In this example, I position the message in the top left, with a larger font size, in pale blue, closer to the horizontal edge and further from the vertical edge.

convert bee.jpg -gravity NorthWest -pointsize 32 -font Helvetica -fill "#cee3f8" -annotate +1+50 "(C) @edent" bee2.jpg
Bee covered in pollen with Helvetica watermark


Adding a watermark to a video is more complex. This will require either ffmpeg - which isn't always installed by default on Linux - or avconv (I don't pretend to understand why ffmpeg and avconv split - but there we are).

I am going to overlay a transparent image on top of the video.

I've created this watermark image with a transparent background.

A transparent watermark

To overlay it, I use:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=1500:1000" output.mp4

or for avconv's overlay:

avconv -i input.mp4 -i watermark.png -filter_complex 'overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10' output.mp4

ffmpeg's overlay= option allows me to specify where the top left of the image will appear on the video. So adjust those number based on the resolution of your watermark and of your video.

avconv has a more complex syntax. It's possible to specify the absolute position using overlay=x=1500:y=1000 or to use relative positions with overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10.

So, there you have it - hopefully simple ways to watermark your media files.

One thought on “Easy ways to add watermarks to images and videos in Linux

  1. For anyone else who read this and immediately asked themselves "but can I get ffmpeg to overlay it without re-encoding the video because my machine is old and slow and that'd take ages", the answer is, no, you can't.

    $ ffmpeg -i foo.mp4 -i yeah.png -filter_complex "overlay=100:100" -vcodec copy /tmp/watermarked.mp4

    Results in the error message: "Streamcopy requested for output stream 0:0, which is fed from a complex filtergraph. Filtering and streamcopy cannot be used together."

    Makes sense, but I had to try it to stop myself wondering "but maybe…".

What do you reckon?

%d bloggers like this: