Created
July 7, 2025 22:23
-
-
Save ExecThTs/9a1315afa612e34f63bdbea5a1263e4a to your computer and use it in GitHub Desktop.
Add a watermark to an image specified as argument. Set size of overlay image in % relative to original image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "processing $1" | |
| watermarklocation=/home/exec/Pictures/watermark.svg | |
| originalsize=$(identify -ping -format '%w %h' "$1") | |
| targetpercentage=25 | |
| watermarkbox=$(awk "BEGIN {print int(( ${originalsize% *} + ${originalsize#* } ) / 2 * ( $targetpercentage * 0.01 ) + 0.5)}" ) | |
| magick composite \ | |
| -background none \ | |
| \( "$watermarklocation" -geometry "$watermarkbox" \) \ | |
| -compose over \ | |
| "$1" \ | |
| -gravity southwest \ | |
| -geometry 50% \ | |
| -quality 95 \ | |
| "$(dirname "$1")/$(basename "$1" .jpg).wm.jpg" | |
| echo "done $(dirname "$1")/$(basename "$1" .jpg).wm.jpg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment