Created
December 13, 2014 16:09
-
-
Save sabas/880da3d5656c4ee52edb to your computer and use it in GitHub Desktop.
Resize photos (found online)
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 | |
for file in ./* | |
do | |
# next line checks the mime-type of the file | |
IMAGE_TYPE=`file --mime-type -b "$file" | awk -F'/' '{print $1}'` | |
if [ "x$IMAGE_TYPE" == "ximage" ]; then | |
WIDTH=`imageinfo --width "$file"` # obtaining the image width | |
HEIGHT=`imageinfo --height "$file"` # obtaining the image height | |
# If the image width is greater that 200 or the height is greater that 150 a thumb is created | |
if [ $WIDTH -ge 201 ] || [ $HEIGHT -ge 151 ]; then | |
#This line convert the image in a 200 x 150 thumb | |
convert -sample 75x50 "$file" "$(dirname "$file")/thumb_$(basename "$file")" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment