Created
February 6, 2015 17:22
-
-
Save josecostamartins/ced5402e161f0eea90c8 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
for FILE in *.jpg; do | |
echo "Processing file: $FILE" | |
WIDTH=`identify $FILE | awk '{split($3,a,"x"); print a[1]}'` | |
HEIGHT=`identify $FILE | awk '{split($3,a,"x"); print a[2]}'` | |
if [ "$WIDTH" -gt 1024 -o "$HEIGHT" -gt 1024 ]; then | |
if [ "$WIDTH" -gt "$HEIGHT" ]; then | |
RATIO=$(echo 1024/$WIDTH | bc -l) | |
else | |
RATIO=$(echo 1024/$HEIGHT | bc -l) | |
fi | |
WIDTH_NEW=$(echo "$WIDTH * $RATIO" | bc -l | python -c "print int(round(float(raw_input())))") | |
HEIGHT_NEW=$(echo "$HEIGHT * $RATIO" | bc -l | python -c "print int(round(float(raw_input())))") | |
#echo "SIZE: $SIZE" | |
#echo "FILE: $FILE" | |
convert $FILE -resize "$WIDTH_NEW"x"$HEIGHT_NEW" "$FILE" | |
#echo "RATIO: $RATIO" | |
#echo "WIDTH: $WIDTH" | |
#echo "HEIGHT: $HEIGHT" | |
#wd="$WIDTH * $RATIO" | bc -l | |
#echo "$w" | |
#php -r 'echo round('$wd');' | |
#echo $(round2 "$wd" 0) | |
#echo `identify $file` | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment