Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 $$
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