-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconv_andr
32 lines (26 loc) · 833 Bytes
/
conv_andr
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
#!/bin/bash
#This script resize big images for my Android device
INPUT_FORMAT=png
if [ -z "$1" -o -z "$2" ]
then
echo "repn: Format isn't correct!"
echo "repn: Use conv_andr path_to_photos/ format number_of_threads"
echo "where format - 480x320 or scaled, use 800x800 for max length/heigth"
echo "Converted images will stored in path_to_photos/converted"
echo "If number_of_threads not entered then using all system processors"
exit
fi
if [ ! -e $1converted ]
then
mkdir $1converted
fi
if [[ -z "$3" || $3 == 0 ]]
then
THREADS=`grep -c processor /proc/cpuinfo`
else
THREADS=$3
fi
echo "Using $THREADS processors"
echo "convert -resize $2 "$1\$@" "$1converted/\$@"" > /tmp/conv_andr_tmp
ls -1 $1 | grep -i $INPUT_FORMAT | xargs -L1 -P$THREADS bash /tmp/conv_andr_tmp
rm -f /tmp/conv_andr_tmp