Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- WIDTH=$1
- if [[ $WIDTH == '' ]]
- then
- echo "Usage: $0 (resize_width_number)"
- echo "Eample: $0 512"
- echo "That will resize picture to width: 512px, height: automaticaly calculated.. :)"
- exit;
- fi
- for i in `ls *.jpg`
- do
- echo -n "Converting file: $i"
- SW=`identify $i|awk '{ print $3 }'|cut -d x -f 1` # width of file
- SH=`identify $i|awk '{ print $3 }'|cut -d x -f 2` # height of file
- let PERCENTAGE=(WIDTH*100)/SW;
- FS=`echo $i|cut -d '.' -f 1`
- FE=`echo $i|cut -d '.' -f 2`
- NF="$FS-resized.$FE"
- echo " to "$SW"px -> "$WIDTH"px("$PERCENTAGE"%) -> $NF"
- convert $i -resize $PERCENTAGE $NF
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement