Created
May 22, 2011 21:54
-
-
Save jjdelc/985936 to your computer and use it in GitHub Desktop.
Resize pictures in folder 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 | |
# | |
# 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