updated on Sun Jan 15 08:01:04 UTC 2012
[aur-mirror.git] / imgmini_convert / imgmini
blob568a678ff70756dbad97ceb20f922ea6562f17f1
1 #!/bin/bash
3 if [ -n "`echo "$@"|grep "\-help"`" ] || [ -n "`echo "$@"|grep "\-h"`" ] || [ -z "$1" ] || [ -z "$2" ]; then
4 echo "imgmini /folder/with/photos/to/minimalization /folder/for/minimalized/photos dpi_pref_600 NOPREF_files_names_without_mini_prefix"
5 exit 0
6 fi
7 if [ -d $1 ]; then
8 cd "$1"
9 else
10 echo "Folder with photos dont exist"
11 exit 0
14 if [ ! -d $2 ]; then
15 `mkdir $2`
18 if [ -n "`echo $3|grep -w '[0-9]\{1,\}'`" ]; then
19 rozmiar="-scale $3"
22 if [ "$4" = "NOPREF" ]; then
23 mini=""
24 else
25 mini="mini-"
28 if [ -n "`ls|grep .jpg`" ];then
29 formaty="$formaty *.jpg"
32 if [ -n "`ls|grep .JPG`" ];then
33 formaty="$formaty *.JPG"
34 fi
36 if [ -n "`ls|grep .png`" ];then
37 formaty="$formaty *.png"
40 if [ -n "`ls|grep .PNG`" ];then
41 formaty="$formaty *.PNG"
44 if [ -n "`ls|grep .gif`" ];then
45 formaty="$formaty *.gif"
46 fi
48 if [ -n "`ls|grep .GIF`" ];then
49 formaty="$formaty *.GIF"
52 `ls -1 $formaty>/tmp/imgminimalize-list`
53 `sed -e '/^mini/d' /tmp/imgminimalize-list > /tmp/imgminimalize-listtmp; mv /tmp/imgminimalize-listtmp /tmp/imgminimalize-list`
54 iloscplikow=`cat /tmp/imgminimalize-list|grep "" -c`
55 i=1
56 while [ $i -le $iloscplikow ]; do
57 orgphoto=`sed -n "$i p;$i q" /tmp/imgminimalize-list`
58 miniphoto="$2/$mini$orgphoto"
59 `convert $rozmiar "$orgphoto" "$miniphoto"`
60 echo $miniphoto
61 i=$[10#$i + 10#1]
62 done
63 `rm /tmp/imgminimalize-list`