Skip to content

Instantly share code, notes, and snippets.

@jjdelc
Created May 22, 2011 21:54
Show Gist options
  • Save jjdelc/985936 to your computer and use it in GitHub Desktop.
Save jjdelc/985936 to your computer and use it in GitHub Desktop.
Resize pictures in folder with ImageMagick
#!/bin/bash
#
# Resize all pictures in a folder
#
# This will modify the files, so MAKE A BACKUP before!
#
# usage:
# $> resizem.sh folder/name
#
echo "Resizing images"
echo $(date)
find $1 -iname '*jpg' | while read fname; do
width=$(identify $fname| cut -d' ' -f3|cut -d'x' -f1)
size=$(stat --printf="%s" $fname)
echo -n "Resizing ${fname}... "
# Uncomment to pick your criteria
#[ $width -gt 1280 ] && \
#mogrify -limit memory 64 -limit map 32 -thumbnail 1280x1280 -quality 70 $fname
[ $size -gt 500000 ] && \
mogrify -limit memory 64 -limit map 32 -thumbnail 1280x1280 -quality 70 $fname
echo "[OK]"
done
echo $(date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment