forked from anilgulecha/misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phoneresizer
executable file
·46 lines (39 loc) · 1013 Bytes
/
phoneresizer
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
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Script to convert all images in current folder to a phone resolution
# removes existing dorectories portrait and landscape in current directory
if [[ $# -lt 2 ]];then
echo "usage : $0 <longerside> <shortersize> [-cbz]"
echo " ex : $0 480 320"
exit 1
fi
rm -rf portrait landscape
mkdir portrait landscape
cbz=0
[[ $3 == "-cbz" ]] && cbz=1
wid=$1
hei=$2
for a in *jpg;
do
w=`identify -format "%w" "$a"`
h=`identify -format "%h" "$a"`
#echo $w $h
if [[ $w -ge $h ]];then
echo " >landscape/$a"
convert -geometry "${wid}x${hei}" -quality 80 "$a" "landscape/$a"
else
echo " >portrait/$a"
convert -geometry "${hei}x${wid}" -quality 80 "$a" "portrait/$a"
fi
done
if [[ "$cbz" == "1" ]];then
curdir=`pwd`
onlydir=`basename $curdir`
cd portrait;
zip -9 "${onlydir}_portrait.cbz" *
mv *.cbz ..
cd ../landscape
zip -9 "${onlydir}_landscape.cbz" *
mv *.cbz ..
cd ..
rm -r landscape portrait
fi