Skip to content

Instantly share code, notes, and snippets.

@tomsaleeba
Created April 16, 2020 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomsaleeba/4b566c800d24e456e24e599dc59b6820 to your computer and use it in GitHub Desktop.
Save tomsaleeba/4b566c800d24e456e24e599dc59b6820 to your computer and use it in GitHub Desktop.
How to add watermarks with ImageMagick
$ magick --version
Version: ImageMagick 7.0.10-3 Q16 x86_64 2020-03-28 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zlib

The command

inputFile=path/to/input.jpg
logoFile=path/to/logo.jpg
outputFile=path/to/output.jpg
convert $inputFile $logoFile -gravity southeast -geometry +100+100 -format jpg -composite $outputFile

This will overlay $logoFile on $inputFile as a watermark. Setting -gravity southeast means the reference point of both where to place to logo and the reference point of the logo are the bottom-right. Setting -geometry +100+100 move the bottom-right of the logo in 100px in x and y from the bottom-right of the main photo. We could also specify geometry like 300x300%+100+100 to blow the logo up to 300% of its size (not the parent image).

Thanks for the command: https://www.imagemagick.org/discourse-server/viewtopic.php?p=143588#p143588

More reading about

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment