Advertisement
goodoldlameme

Untitled

Nov 11th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ "$1" == '-h' -o "$1" == '--help' ];
  4. then
  5. echo "scriptname, results directory, 'width'x'height'";
  6. exit 0;
  7. fi
  8.  
  9. if [ -f "$1" -o -z "$2" ];
  10. then
  11. echo "There're not enough parameters";
  12. exit 0;
  13. fi
  14.  
  15. source_dir=$(pwd);
  16. results_dir="$1";
  17. result_width=$( echo "$2" | cut -d 'x' -f 1 );
  18. result_height=$( echo "$2" | cut -d 'x' -f 2 );
  19.  
  20. if [ -d "$results_dir" ]
  21. then
  22. echo "Directory $results_dir already exists";
  23. exit 0;
  24. else
  25. mkdir $results_dir;
  26. fi
  27.  
  28.  
  29. for pic in $source_dir/*.*[jJ][pP][gG]*;
  30. do
  31. picname="${pic##*/}";
  32. echo "$picname";
  33. file_res=$( identify "$pic" | awk '{print $3}' );
  34. width=$( echo "$file_res" | cut -d 'x' -f 1 );
  35. height=$( echo "$file_res" | cut -d 'x' -f 2 );
  36. if [ "$width" -ge "$result_width" -o "$height" -ge "$result_height" ]
  37. then
  38. convert -resize "$result_width"'x'"$result_height" "$pic" "$results_dir"/"$picname";
  39. fi
  40.  
  41. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement