aboutsummaryrefslogtreecommitdiff
path: root/convert/contrib/web-gallery
blob: f2b90f4291c10cad24b059f03eee2b3c4882e8a2 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash

# Nautilus script to generate image galleries for use with original
# uses Gnome's zenity for user dialogs
# uses ImageMagick's convert
# (c) 2005 boris de laage  <bdelaage@free.fr>
# based on imgconv bu Jakub Steiner

set -e

name=`basename $0`

# convert options
convertor=`which convert`
extra_ops="-strip"

#default options
dir=./web-gallery

files=$(echo $@ | sed 's/ /\n/g' | sort)
numfiles=$#


if [ -z $convertor ]; then
    zenity --title $name --error --text "convert not found !"
    exit 1
fi

if [ $numfiles == 0 ]; then
    zenity --title $name  --error --text "No input files !"
    exit 1
fi


mkdir -p $dir/thumbs
mkdir -p $dir/lq
mkdir -p $dir/mq
mkdir -p $dir/hq
mkdir -p $dir/zip
mkdir -p $dir/comments
chmod o+w $dir/comments

echo "<Files info.txt>" > $dir/.htaccess
echo "        deny from all" >> $dir/.htaccess
echo "</Files>" >> $dir/.htaccess

# stuf for the progressbar
step=5
max=`expr $step \* $numfiles + $step`

i=1

for imagefile in $files
  do
  process="converting $imagefile"

      # Thumbnail
  echo "#$process : thumbnail"
  $convertor -geometry 120x120 -modulate 100,140,100 -unsharp 1x20 \
      -quality 60 $extra_opts $imagefile $dir/thumbs/img-$i.jpg
  progress=`expr \( $i \* $step + 1 \) \* 100 / $max`

  echo $progress

      # LQ
  echo "#$process : lq"
  $convertor -geometry 640x480 -modulate 100,130,100 -unsharp 1x5 \
      -quality 90 $imagefile $dir/lq/img-$i.jpg
  progress=`expr \( $i \* $step + 2 \) \* 100 / $max`
  echo $progress

      #�MQ
  echo "#$process : mq"
  $convertor -geometry 1024x768 -modulate 100,130,100 -unsharp 1x5 \
      -quality 80 $imagefile $dir/mq/img-$i.jpg
  progress=`expr \( $i \* $step + 3 \) \* 100 / $max`
  echo $progress

      #�HQ
  echo "#$process : hq"
  cp $imagefile $dir/hq/img-$i.jpg
  progress=`expr \( $i \* $step + 4 \) \* 100 / $max`
  echo $progress

      #�Comments
  echo "#$process : comments"
      # template for comment
  echo "<span>Photo $i</span>" > $dir/comments/$i.txt
  progress=`expr \( $i \* $step + 5 \) \* 100 / $max`
  echo $progress

  i=`expr $i + 1`

done | zenity --progress --title="Scaling images, please wait..." --auto-close


(
    echo "1"
    echo "#Making archives"
    zip -R $dir/zip/mq.zip  web-gallery/mq/*.jpg
    echo "50"
    zip -R $dir/zip/hq.zip web-gallery/hq/*.jpg
    echo "100"
) | zenity --progress --pulsate --auto-close --title="Zipping images"

zenity --title $name --info --text "Your <b>O.R.I.G.I.N.A.L</b> gallery is ready."