Created
June 24, 2017 02:47
-
-
Save rbrady/01b535ec908c0c75ae8941de706e828b to your computer and use it in GitHub Desktop.
Resize and Watermark images with ImageMagick
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 | |
# change dir to the first arg to the script | |
cd $1 | |
if [[ "$2" != "" ]]; then | |
FONT_TYPE="$2" | |
else | |
FONT_TYPE="Helvetica" | |
fi | |
if [[ "$3" != "" ]]; then | |
ALT_FONT_TYPE="$3" | |
else | |
ALT_FONT_TYPE="Helvetica" | |
fi | |
# create resized dir | |
mkdir resized | |
# lookup files with extension | |
for fname in *.*; do | |
final_file="./resized/$(echo $fname | cut -d'.' -f1).png" | |
# resize, sharpen and convert | |
echo "processing $fname" | |
mogrify -quality 96% -format png -write "$final_file" -resize 12% "$fname" | |
# watermark | |
echo "watermarking $final_file, using $FONT_TYPE" | |
convert "$final_file" -font $FONT_TYPE -pointsize 36\ | |
-draw "gravity center \ | |
fill white text 0,-20 'Monica Brady Photography' " \ | |
"$final_file" | |
convert "$final_file" -font $ALT_FONT_TYPE -pointsize 32 \ | |
-draw "gravity center \ | |
fill white text 5,30 'monicabrady.net' " \ | |
"$final_file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment