Created
August 4, 2019 07:50
-
-
Save hgwr/478960389523a47d984573bea31944d9 to your computer and use it in GitHub Desktop.
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 | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
trap 'echo "Ctrl-C captured and exit."; exit 1' INT | |
trap 'echo "some error occured at $(pwd) and exit."; exit 8' SIGHUP | |
mkdir -p outdir || exit 1 | |
find . -type f \( -iname '*.jpg' -or -iname '*.png' -or -iname '*.jpeg' -or -iname '*.gif' \) -print0 | \ | |
while read -d $'\0' i; do | |
echo convert "$i" -geometry 1200x -compress jpeg -quality 85 "outdir/${i%.*}.jpg" | |
convert "$i" -geometry 1200x -compress jpeg -quality 85 "outdir/${i%.*}.jpg" || kill -hup $$ | |
done | |
rm -f *.jpg *.png *.JPG *.PNG *.JPEG && \ | |
mv outdir/* . && \ | |
rm -rf outdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment