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.
convert bee.jpg -gravity SouthEast -pointsize 16 -font TinyUnicode-Medium -fill "#fffdc3" -annotate +10+10 "(C) @edent" bee1.jpg
It produces this:
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.
-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
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.
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
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
Or, for a one-liner:
ffmpeg -i input.mp4 -vf "drawtext=text='@edent':x=10:y=H-th-10:fontfile=/home/edent/.local/share/fonts/OCRAEXT.TTF:fontsize=15:fontcolor=#cee3f8" -vcodec h264 -strict -2 output.mp4
So, there you have it - hopefully simple ways to watermark your media files.