Created
October 8, 2020 15:57
-
-
Save marcelotmelo/693f0e93630207c05e77313ac84cd8d9 to your computer and use it in GitHub Desktop.
Add watermark to file
This file contains 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
#!/bin/bash | |
# needs imagemagick | |
set -e | |
help() { | |
echo "Adds a watermark text to an image. Generates a new image file with the given watermark." | |
echo "Usage: $0 <source> <destination> <watermark> [size]" | |
echo -e "\tsource: The original image file which the watermark text will be added to." | |
echo -e "\tdestination: The generated image with the watermark text added." | |
echo -e "\twatermark: The text that will be added as a watermark to the image." | |
echo -e "\tsize (optional): The text size. Defaults to 80 if not informed." | |
exit 1 | |
} | |
if [ "$#" -lt 3 ] | |
then | |
help | |
fi | |
SOURCE=$1 | |
DEST=$2 | |
TEXT=$3 | |
SIZE=${4:-80} | |
convert -density 150 -fill "rgba(255,0,0,0.25)" -gravity Center -pointsize $SIZE -draw "rotate -45 text 0,0 \"$TEXT\"" "$SOURCE" "$DEST" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment