aboutsummaryrefslogtreecommitdiff
path: root/convert/contrib/web-gallery
blob: 952f8fe3e0ea0b5b09f17f3cb36585b61af4f660 (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
#!/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 --error-text "convert not found !"
    exit 1
fi

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

#progressbar stuff
steps=5
increment=`expr 100 / \( $numfiles \* $steps \) `
progress=0


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


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 $progress + $increment`
  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 $progress + $increment`
  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 $progress + $increment`
  echo $progress

      #�HQ
  echo "#$process : hq"
  cp $imagefile $dir/hq/img-$i.jpg
  progress=`expr $progress + $increment`
  echo $progress

      #�Comments
  echo "#$process : comments"
      # template for comment
  echo "<span>Photo $i</span>
" > $dir/comments/$i.txt
  progress=`expr $progress + $increment`
  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
    zip -R $dir/zip/hq.zip web-gallery/hq/*.jpg
    echo "100"
) | zenity --progress --pulsate --auto-close --title="Zipping images"

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