Debian Codegraph @

jigl2slideshow

raw
1 #!/bin/bash
2 # jigl2slideshow
3 # Copyright 2003 Scott Merrill <skippy at skippy.net>
4 # adapted from gallery2slideshow by Scott Dylewski <scott at dylewski.com>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #
20 version='0.4'
21 changes ()
22 {
23 echo ' Changes:
24 0.4 -i switch not required for input file
25 0.3 Added fadein before first picture and fadeout at the end
26 0.2 Scott <scott at dylewski.com> Changed typo [ -n $output_dir ]
27 to [ -z $output_dir ]
28 0.1 Initial release'
29 }
30
31 # set defaults
32 duration="10";
33 output_dir="";
34 gallery_path="";
35 crossfade=0
36
37 help ()
38 {
39 echo "jigl2slideshow $version"
40 echo "jigl2slideshow is part of the dvd-slideshow set of tools."
41 echo 'http://freshmeat.net/dvdslideshow'
42 echo 'Copyright 2003 Scott Merrill <skippy at skippy.net>'
43 echo 'Copyright 2003 Scott Dylewski <scott at dylewski.com>'
44 echo
45 echo '
46 jigl2slideshow description:
47 Generates a text file listing of the pictures visible in a given
48 jigl (http://xome.net/projects/jigl/) photo album
49 in order to easily pass the information to dvd_slideshow
50
51 Usage: jigl2slideshow -o <output_file> -t <time_per_picture> <path_to_album>
52
53 Options:
54 path_to_album
55 Path to the gallery.dat that you want to generate a slideshow for.
56
57 -o output_directory
58 Path to the directory where you want to output file written.
59
60 -t time_per_picture
61 Integer number of seconds for each picture to be displayed.
62
63 -h or -help
64 Prints this help.'
65 }
66
67 if [ $# -lt 1 ]; then
68 help
69 exit 1
70 fi
71
72
73 ## setup initial variables:
74 debug=0 # 1 or 0
75
76 for arg
77 do
78 case "$arg" in
79 -i) shift ; gallery_path="$1" ; shift ;;
80 -o) shift; output_dir="$1"; shift ;;
81 -t) shift; duration="$1"; shift ;;
82 # need to do more work to get this working:
83 # -c) shift; crossfade=1; crossfade_duration="$1"; shift ;;
84 -h) help ; exit 0 ; shift ;;
85 -?) help ; exit 0 ; shift ;;
86 -help) help ; exit 0 ; shift ;;
87 esac
88 done
89 if [ -z "$gallery_path" ] ; then
90 gallery_path="$1"
91 fi
92 if [ -z "$gallery_path" ] ; then
93 echo "[jigl2slideshow] Error: No album specified"
94 exit 1
95 fi
96
97
98 # sanity checking
99 # did the user give us a valid input file to work with?
100 if [ ! -f $gallery_path ]; then
101 # it's not a regular file
102 if [ ! -d $gallery_path ]; then
103 # it's not a directory!
104 echo "Bogus input file (-i $gallery_path)!"
105 exit 1;
106 else
107 # it is a directory, so use gallery.dat
108 echo "*** Using gallery.dat in $gallery_path";
109 gallery="gallery.dat";
110 if [ ! -f $gallery_path/$gallery ]; then
111 # there's no gallery.dat file there!
112 echo "No such file $gallery_path/$gallery!";
113 echo "Aborting!";
114 exit 1;
115 fi
116 fi
117 else
118 # it is a regular file!
119 gallery=`basename "${gallery_path}"`;
120 gallery_path=`echo $gallery_path | sed -e "s/$gallery//"`;
121 fi
122
123 # make sure $gallery_path has no trailing slash
124 gallery_path=`echo $gallery_path | sed -e 's/\/$//'`;
125
126 # did the user give us a valid destination directory?
127 # if I was really good, I'd check permissions to ensure we can _write_ there
128 # but I suck and should be destroyed
129 if [ -z $output_dir ]; then
130 # no output directory specified!
131 echo "Invalid output destination (-o $output_dir)!";
132 echo "*** Using $gallery_path instead.";
133 output_dir=$gallery_path;
134 fi
135 if [ ! -d $output_dir ]; then
136 # I'm sure it was a simple typo.
137 echo "Invalid output destination (-o $output_dir)!";
138 echo "*** Using $gallery_path instead.";
139 output_dir=$gallery_path;
140 fi
141
142 # make sure $output_dir has no trailing slash
143 output_dir=`echo $output_dir | sed -e 's/\/$//'`;
144
145 cleanup ()
146 {
147 ## clean up temporary files
148 echo "All done!";
149 echo "Enjoy your new $output_dir/pictures_list.txt!";
150 }
151
152 forcequit () ## function gets run when we have some sort of forcequit...
153 {
154 ## clean up temporary files
155 cleanup
156 }
157
158 trap 'forcequit' INT
159 trap 'forcequit' KILL
160 trap 'forcequit' TERM
161
162 ## snag the title from the gallery.dat file
163 title_bit="INDEX-TITLE ---- ";
164 title=`grep "$title_bit" $gallery_path/$gallery | sed -e "s/$title_bit//"`;
165 echo title:$duration:$title > $output_dir/picture_list.txt;
166
167 ## fade in after title:
168 echo "background:1" >> "${output_dir}/picture_list.txt"
169 echo "fadein:1" >> "${output_dir}/picture_list.txt"
170
171 `grep -i .jpg $gallery_path/$gallery | sed -e "s/ ---- /:$duration:/" -e "s#^#$gallery_path/#" >> $output_dir/picture_list.txt`;
172
173 ## fade out at end
174 echo "fadeout:1" >> "${output_dir}/picture_list.txt"
175 echo "background:1" >> "${output_dir}/picture_list.txt"
176
177 cleanup
178