Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. WIDTH=$1
  4. if [[ $WIDTH == '' ]]
  5. then
  6. echo "Usage: $0 (resize_width_number)"
  7. echo "Eample: $0 512"
  8. echo "That will resize picture to width: 512px, height: automaticaly calculated.. :)"
  9. exit;
  10. fi
  11.  
  12. for i in `ls *.jpg`
  13. do
  14. echo -n "Converting file: $i"
  15. SW=`identify $i|awk '{ print $3 }'|cut -d x -f 1` # width of file
  16. SH=`identify $i|awk '{ print $3 }'|cut -d x -f 2` # height of file
  17. let PERCENTAGE=(WIDTH*100)/SW;
  18. FS=`echo $i|cut -d '.' -f 1`
  19. FE=`echo $i|cut -d '.' -f 2`
  20. NF="$FS-resized.$FE"
  21. echo " to "$SW"px -> "$WIDTH"px("$PERCENTAGE"%) -> $NF"
  22. convert $i -resize $PERCENTAGE $NF
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement