-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresizer.sh
executable file
·36 lines (29 loc) · 887 Bytes
/
resizer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
while getopts d:f:s: option
do
case "${option}"
in
d) DESTINATION=${OPTARG};;
f) FOLDER=${OPTARG};;
s) SIZE=${OPTARG};;
esac
done
if [[ -z $FOLDER || -z $DESTINATION || -z $SIZE ]]; then
echo "Arg missing"
exit 1
fi
if [[ ! -d ${DESTINATION} ]]; then
mkdir ${DESTINATION}
fi
for pic in ${FOLDER}/*; do
if [[ -f ${pic} ]]; then
file_name=$(basename ${pic})
convert ${pic} -verbose -quality 75 -resize "${SIZE}^" ${DESTINATION}/${file_name}
fi
done
#resize to either height or width, keeps proportions using imagemagick
#find ${FOLDER} -iname '*.jpg' -o -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
#find ${FOLDER} -iname '*.jpg' -exec identify -format '%[EXIF:Orientation]' {} \;
#find ${FOLDER} -iname '*.jpg' -exec echo {} \;
# alternative
#mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png -verbose