Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ "$1" == '-h' -o "$1" == '--help' ];
- then
- echo "scriptname, results directory, 'width'x'height'";
- exit 0;
- fi
- if [ -f "$1" -o -z "$2" ];
- then
- echo "There're not enough parameters";
- exit 0;
- fi
- source_dir=$(pwd);
- results_dir="$1";
- result_width=$( echo "$2" | cut -d 'x' -f 1 );
- result_height=$( echo "$2" | cut -d 'x' -f 2 );
- if [ -d "$results_dir" ]
- then
- echo "Directory $results_dir already exists";
- exit 0;
- else
- mkdir $results_dir;
- fi
- for pic in $source_dir/*.*[jJ][pP][gG]*;
- do
- picname="${pic##*/}";
- echo "$picname";
- file_res=$( identify "$pic" | awk '{print $3}' );
- width=$( echo "$file_res" | cut -d 'x' -f 1 );
- height=$( echo "$file_res" | cut -d 'x' -f 2 );
- if [ "$width" -ge "$result_width" -o "$height" -ge "$result_height" ]
- then
- convert -resize "$result_width"'x'"$result_height" "$pic" "$results_dir"/"$picname";
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement