]> git.sommitrealweird.co.uk Git - bpgallery.git/blob - bpgallery.sh
e532c68573b38e6720fe6b7840d70d7b832341c3
[bpgallery.git] / bpgallery.sh
1 #!/usr/bin/env bash
2
3 # bpgallery.sh - builds a simple 'gallery' from a collection of images
4 # Copyright (C) 2004 Brett Parker <iDunno@sommitrealweird.co.uk>
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 set -f
21
22 VERSION="1.1.1+arch"
23
24 function bpgallery_default_head() {
25 cat <<END
26 <?xml version="1.0"?>
27 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
28 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
29 <head>
30         <title>${TITLE}</title>
31         <link rel="stylesheet" href="${BASEURL}style.css" type="text/css" />
32 </head>
33 <body>
34 END
35 }
36
37 declare -rf bpgallery_default_head
38
39 function bpgallery_default_description() {
40 cat <<END
41         <h1>${TITLE}</h1>
42         ${DESCRIPTION}
43 END
44 }
45
46 declare -rf bpgallery_default_description
47
48 function bpgallery_default_thumbsline() {
49 if [[ -z $caption ]]; then
50         caption_alt=Unknown
51 else
52         caption_alt=$caption
53 fi
54 cat << END
55 <div class="thumbnail"><a href="$link"><img src="icons/$filename" alt="$caption_alt" /></a><div class="caption">$caption</div></div>
56 END
57 }
58
59 declare -rf bpgallery_default_thumbsline
60
61 function bpgallery_default_tail() {
62 cat << END
63 </body>
64 </html>
65 END
66 }
67
68 declare -rf bpgallery_default_tail
69
70 function bpgallery_default_stylesheet() {
71 cat <<END
72 body {
73         background: white;
74         color: black;
75         font-family: sans-serif;
76         font-size: 10pt;
77 }
78
79 div.thumbnail {
80         float: left;
81         padding: 20px;
82         border: 0px;
83         width: ${WIDTH}px;
84         height: ${MAXHEIGHT}px;
85 }
86
87 div.caption {
88         width: 100%;
89         text-align: center;
90         font-weight: bold;
91 }
92
93 div.navigation {
94         margin: 0;
95 }
96
97 div.navigation ul {
98         display: inline;
99         margin: 0;
100         padding: 0;
101         text-align: center;
102 }
103
104 div.navigation ul li {
105         display: inline;
106         margin: 2em;
107 }
108
109 a {
110         border: 0px;
111 }
112
113 img {
114         border: 0px;
115 }
116 END
117 }
118
119 declare -rf bpgallery_default_stylesheet
120
121 function bpgallery_default_page() {
122         $BPGALLERY_HEAD_FUNCTION
123
124         linkstart=""
125         linkend=""
126
127         if [[ ! -z $linklocation ]]; then
128                 linkstart="<a href='$linklocation'>"
129                 linkend="</a>"
130         fi
131         
132         cat <<END
133 <h1>${caption}</h1>
134 <div class="navigation">
135         <ul>
136                 <li><a href='${BASEURL}${INDEXDOCUMENT}'>Thumbnails</a></li>
137 END
138         if [[ ! -z $previouspage ]]; then
139                 $ECHOCOMMAND "<li><a href='${previouspage}'>Previous</a></li>"
140         else
141                 $ECHOCOMMAND "<li>Previous</li>"
142         fi
143
144         if [[ ! -z $nextpage ]]; then
145                 $ECHOCOMMAND "<li><a href='${nextpage}'>Next</a></li>"
146         else
147                 $ECHOCOMMAND "<li>Next</li>"
148         fi
149 cat <<END
150         </ul>
151 </div>
152 <div class="mainimage">
153         ${linkstart}<img src="${filename}" alt="${caption}" />${linkend}
154 </div>
155 END
156         $BPGALLERY_TAIL_FUNCTION
157 }
158
159 declare -rf bpgallery_default_page
160
161 function bpgallery_escape_url() {
162         temp=$1
163         temp=${temp//\%/%25}
164         temp=${temp//:/%3A}
165         temp=${temp//;/%3B}
166         temp=${temp// /%20}
167         temp=${temp//$/%24}
168         temp=${temp//&/%26}
169         temp=${temp//+/%2B}
170         temp=${temp//,/%2C}
171         temp=${temp//\//%2F}
172         temp=${temp//=/%3D}
173         temp=${temp//\?/%3F}
174         temp=${temp//@/%40}
175         temp=${temp//\"/%22}
176         $ECHOCOMMAND $temp
177 }
178
179 declare -rf bpgallery_escape_url
180
181 if [[ ! -z ${BPGALLERY_THEME} ]] ; then
182         declare -r BPGALLERY_THEME
183 fi
184
185 if [[ ! -z ${TITLE} ]] ; then
186         declare -r TITLE
187 fi
188
189 if [[ -e /usr/local/etc/bpgallery/config ]] ; then
190         . /usr/local/etc/bpgallery/config 2>/dev/null
191 fi
192
193 if [[ -e /etc/bpgallery/config ]] ; then
194         . /etc/bpgallery/config 2>/dev/null
195 fi
196
197 if [[ -e $HOME/.bpgallery.rc ]]; then
198         . $HOME/.bpgallery.rc 2>/dev/null
199 fi
200
201 if [[ -e $1 && -d $1 && -e $1/.bpgallery.rc ]]; then
202         . $1/.bpgallery.rc 2>/dev/null
203 fi
204
205 if [[ -z ${BPGALLERY_THEME} ]]; then
206         BPGALLERY_THEME=default
207 fi
208
209 if [[ ! -z ${BPGALLERY_THEME_DIR} ]] && \
210         [[ -e ${BPGALLERY_THEME_DIR}/${BPGALLERY_THEME} ]]; then
211         . ${BPGALLERY_THEME_DIR}/${BPGALLERY_THEME} 2>/dev/null
212 elif [[ -e $HOME/.bpgallery.themes/${BPGALLERY_THEME} ]]; then
213         . $HOME/.bpgallery.themes/${BPGALLERY_THEME} 2>/dev/null
214 elif [[ -e /usr/local/etc/bpgallery/themes/${BPGALLERY_THEME} ]]; then
215         . /usr/local/etc/bpgallery/themes/${BPGALLERY_THEME} 2>/dev/null
216 elif [[ -e /etc/bpgallery/themes/${BPGALLERY_THEME} ]]; then
217         . /etc/bpgallery/themes/${BPGALLERY_THEME} 2>/dev/null
218 fi
219
220 if [[ -z $TITLE ]]; then 
221         TITLE="Photo Gallery"
222 fi
223
224 if [[ -z $CONVERTTOOL ]]; then
225         CONVERTTOOL=convert
226 fi
227
228 if [[ -z $FINDCOMMAND ]]; then
229         FINDCOMMAND=find
230 fi
231
232 if [[ -z $XARGSCOMMAND ]]; then
233         XARGSCOMMAND=xargs
234 fi
235
236 if [[ -z $ECHOCOMMAND ]]; then
237         ECHOCOMMAND=echo
238 fi
239
240 if [[ -z $SORTCOMMAND ]]; then
241         SORTCOMMAND=sort
242 fi
243
244 if [[ -z $IDENTIFYCOMMAND ]]; then
245         IDENTIFYCOMMAND=identify
246 fi
247
248 if [[ -z $HEADCOMMAND ]]; then
249         HEADCOMMAND=head
250 fi
251
252 if [[ -z $GREPCOMMAND ]]; then
253         GREPCOMMAND=grep
254 fi
255
256 if [[ -z $SEDCOMMAND ]]; then
257         SEDCOMMAND=sed
258 fi
259
260 if [[ -z $WIDTH ]]; then
261         WIDTH=100
262 fi
263
264 if [[ -z $IMAGEEXTENSIONS ]]; then
265         IMAGEEXTENSIONS="jpeg jpg gif png";
266 fi
267
268 if [[ -z $WCCOMMAND ]]; then
269         WCCOMMAND="wc -l"
270 fi
271
272 if [[ -z $CAPTIONHEIGHT ]]; then
273         CAPTIONHEIGHT=75
274 fi
275
276 if [[ -z $OUTPUTHTML ]]; then
277         OUTPUTHTML=0
278 fi
279
280 if [[ -z $GENERATEPAGESFORFULLSIZE ]]; then
281         GENERATEPAGESFORFULLSIZE=0
282 fi
283
284 if [[ -z $GENERATEPAGESFORMEDIUMSIZE ]]; then
285         GENERATEPAGESFORMEDIUMSIZE=1
286 fi
287
288 if [[ -z $PAGESDIRECTORY ]]; then
289         PAGESDIRECTORY=""
290 else
291         temp=${PAGESDIRECTORY:${#PAGESDIRECTORY}-1:1}
292         if [[ "x$temp" != "x/" ]] && [[ "x$temp" != "x\\" ]]; then
293                 PAGESDIRECTORY=${PAGESDIRECTORY}/
294         fi
295 fi
296
297 if [[ -z $MEDIUMWIDTH ]]; then
298         MEDIUMWIDTH=400
299 fi
300
301 if [[ -z $INDEXDOCUMENT ]]; then
302         INDEXDOCUMENT=index.html
303 fi
304
305 if declare -F "bpgallery_${BPGALLERY_THEME}_page" > /dev/null ; then
306         BPGALLERY_PAGE_FUNCTION="bpgallery_${BPGALLERY_THEME}_page"
307 else
308         BPGALLERY_PAGE_FUNCTION="bpgallery_default_page"
309 fi
310
311 if declare -F "bpgallery_${BPGALLERY_THEME}_head" > /dev/null ; then
312         BPGALLERY_HEAD_FUNCTION="bpgallery_${BPGALLERY_THEME}_head"
313 else
314         BPGALLERY_HEAD_FUNCTION="bpgallery_default_head"
315 fi
316
317 if declare -F "bpgallery_${BPGALLERY_THEME}_description" > /dev/null ; then
318         BPGALLERY_DESCRIPTION_FUNCTION="bpgallery_${BPGALLERY_THEME}_description"
319 else
320         BPGALLERY_DESCRIPTION_FUNCTION="bpgallery_default_description"
321 fi
322
323 if declare -F "bpgallery_${BPGALLERY_THEME}_thumbsline" > /dev/null ; then
324         BPGALLERY_THUMBSLINE_FUNCTION="bpgallery_${BPGALLERY_THEME}_thumbsline"
325 else
326         BPGALLERY_THUMBSLINE_FUNCTION="bpgallery_default_thumbsline"
327 fi
328
329 if declare -F "bpgallery_${BPGALLERY_THEME}_tail" > /dev/null ; then
330         BPGALLERY_TAIL_FUNCTION="bpgallery_${BPGALLERY_THEME}_tail"
331 else
332         BPGALLERY_TAIL_FUNCTION="bpgallery_default_tail"
333 fi
334
335 if declare -F "bpgallery_${BPGALLERY_THEME}_stylesheet" > /dev/null ; then
336         BPGALLERY_STYLESHEET_FUNCTION="bpgallery_${BPGALLERY_THEME}_stylesheet"
337 else
338         BPGALLERY_STYLESHEET_FUNCTION="bpgallery_default_stylesheet"
339 fi
340
341 FINDIMAGESOPTIONS=""
342
343 for imageext in $IMAGEEXTENSIONS; do
344         FINDIMAGESOPTIONS=$FINDIMAGESOPTIONS' -o -type f -iname '*.$imageext' -print0'
345 done
346
347 FINDIMAGESOPTIONS=${FINDIMAGESOPTIONS## -o }
348 FINDIMAGESOPTIONS='-maxdepth 1 '${FINDIMAGESOPTIONS}
349
350 function usage() {
351 cat <<END
352 Usage:
353   $0 [--help|--version|<path to images>]
354
355     --help
356         displays this help screen
357     --version
358         displays the version and exits
359
360 This can also takes some environment variables, these will use defaults if not
361 set.
362
363         TITLE
364             the title of the gallery
365
366         WIDTH
367             the width to make the icons
368
369         MEDIUMWIDTH
370             set the width of images in the medium size pages
371
372         BPGALLERY_THEME
373             set the theme to use (described below)
374
375         BPGALLERY_THEME_DIR
376             set an extra location to look for themes
377
378         OUTPUTHTML
379             sets the script output to be wrapped in a <pre> block
380
381         GENERATEPAGESFORMEDIUMSIZE
382             generate medium sized images and pages
383
384         GENERATEPAGESFORFULLSIZE
385             decide wether to generate pages for the full size images or not
386
387         INDEXDOCUMENT
388             name of the index page (e.g. index.html)
389
390 Example:
391         TITLE="My Funky Gallery" WIDTH=200 INDEXDOCUMENT="welcome.html" GENERATEPAGESFORFULLSIZE=1 GENERATEPAGESFORMEDIUMSIZE=1 MEDIUMWIDTH=400 $0 /path/to/image/folder
392 END
393 }
394
395 function version() {
396 cat <<END
397 Version: $VERSION
398 END
399 }
400
401 function generate_resized_images() {
402         $ECHOCOMMAND "Generating $2"
403         currentimage=0
404         totalimages=$($FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 -I {} $ECHOCOMMAND {} | $WCCOMMAND);
405         imagestoupdate=$($FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 -I {} $ECHOCOMMAND {} | while read filename; do filename=${filename//\"/\\\"}; if [ ! -r "$2/$filename" ] || [ "$filename" -nt "$2/$filename" ] || [ $($IDENTIFYCOMMAND -format "%w" "$2/$filename") -ne $1 ]; then $ECHOCOMMAND $filename; fi; done | $WCCOMMAND)
406         
407         if [ $totalimages -eq 0 ]; then
408                 # might as well exit at this point - there are no pictures
409                 $ECHOCOMMAND "No images for the gallery - exiting."
410                 exit 64
411         else
412                 # check if the directory exists and create it other wise
413                 if [ ! -d $2 ]; then
414                         mkdir $2
415                 fi
416
417                 if [ ! -w $2 ]; then
418                         $ECHOCOMMAND "Can't write to $2 directory, exiting"
419                         exit 16
420                 fi
421         fi
422
423         if [ $totalimages -eq $imagestoupdate ]; then
424                 $ECHOCOMMAND "Regenerating all $2"
425         elif [ $imagestoupdate -eq 0 ]; then
426                 $ECHOCOMMAND "No Updated $2, not regenerating"
427                 return
428         else
429                 $ECHOCOMMAND "Generating $imagestoupdate of $totalimages $2"
430         fi
431         
432         $FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 -I {} $ECHOCOMMAND {} | while read filename; do tempfilename=${filename//\"/\\\"/}; if [ ! -r "$2/$tempfilename" ] || [ "$tempfilename" -nt "$2/$tempfilename" ] || [ $($IDENTIFYCOMMAND -format "%w" "$2/$filename") -ne $1 ]; then $ECHOCOMMAND -n $filename; $ECHOCOMMAND -n -e "\000"; fi; done | $XARGSCOMMAND -0 --verbose --max-procs=4 -I {} $CONVERTTOOL -resize $1 '{}' $2/'{}' 2>&1 | while read throwout; do $ECHOCOMMAND done: $currentimage/$imagestoupdate images; currentimage=$((currentimage+1)); done
433         $ECHOCOMMAND done: $imagestoupdate/$imagestoupdate images
434         $ECHOCOMMAND "Completed generating $2 for $totalimages images"
435 }
436
437 function generate_thumbs() {
438         generate_resized_images $WIDTH icons
439 }
440
441 function generate_medium() {
442         generate_resized_images $MEDIUMWIDTH medium
443 }
444
445 function generate_pages() {
446         $ECHOCOMMAND "Generating Pages"
447         previouspage=""
448         currentpage=""
449         nextpage=""
450         previousimage=""
451         currentimage=""
452         nextimage=""
453         extra=""
454         extradir=""
455         addlinks=0
456         
457         if [ ! -z $1 ]; then
458                 extra=$1
459         fi
460
461         if [ ! -z $2 ]; then
462                 extradir=$2/
463                 addlinks=1
464         fi
465
466         if [ -z $2 ] && [[ $GENERATEPAGESFORMEDIUMSIZE != 0 ]]; then
467                 addlinks=2
468         fi
469         
470         $FINDCOMMAND . $FINDIMAGESOPTIONS | \
471         $XARGSCOMMAND -0 -I {} $ECHOCOMMAND {} | \
472         $SORTCOMMAND -g | \
473         while read imagefilename; do
474                 previousimage=$currentimage
475                 currentimage=$nextimage
476                 nextimage=${imagefilename#./}
477                 addlink=""
478                 
479                 if [[ $GENERATEPAGESFORFULLSIZE != 0 ]]; then
480                         if [[ $addlinks == 1 ]]; then
481                                 addlink=${currentimage}.html
482                         else
483                                 addlink=${currentimage}${extra}.html
484                         fi
485                 else
486                         addlink=${currentimage}
487                 fi
488
489                 previouspage=$currentpage
490                 currentpage=$nextpage
491                 if [[ $addlinks == 1 ]]; then
492                         nextpage=${nextimage}${extra}.html
493                 else
494                         nextpage=${nextimage}.html
495                 fi
496
497                 if [[ "x$PAGESDIRECTORY" != "x" ]]; then
498                         filename=../${extradir}${currentimage}
499                 else
500                         filename=${extradir}${currentimage}
501                 fi
502                 if [ "x$currentpage" != "x" ]; then
503                         generate_general_page "$previouspage" "$currentpage" "$nextpage" $addlink
504                 fi
505                 $ECHOCOMMAND $nextimage
506         done | tail -n 2 | (
507                 read previouspage
508                 read currentpage
509                 addlink=""
510
511                 if [[ $GENERATEPAGESFORFULLSIZE != 0 ]]; then
512                         if [[ $addlinks == 1 ]]; then
513                                 addlink=${currentpage}.html
514                         else
515                                 addlink=${currentpage}${extra}.html
516                         fi
517                 else
518                         addlink=${currentpage}
519                 fi
520                 
521                 if [[ "x$PAGESDIRECTORY" != "x" ]]; then
522                         filename=../${extradir}${currentpage}
523                 else
524                         filename=${extradir}${currentpage}
525                 fi
526                 if [[ $addlinks == 1 ]]; then
527                         currentpage=${currentpage}${extra}.html
528                         previouspage=${previouspage}${extra}.html
529                 else
530                         currentpage=${currentpage}.html
531                         previouspage=${previouspage}.html
532                 fi
533                 nextpage=""
534                 generate_general_page "$previouspage" "$currentpage" "" $addlink
535         )
536 }
537
538 function generate_medium_pages() {
539         generate_pages __medium medium
540 }
541
542 function generate_general_page() {
543
544         if [[ -z $1 ]]; then
545                 previouspage=""
546         fi
547
548         if [[ -z $2 ]]; then
549                 currentpage=""
550                 return
551         fi
552
553         if [[ -z $3 ]]; then
554                 nextpage=""
555         fi
556
557         if [[ ! -z $4 ]]; then
558                 linklocation=$4
559         fi
560
561         if [ -r captions.txt ]; then
562                 imagefilename=${filename##*/}
563                 caption=$($GREPCOMMAND -E "^${imagefilename}    " captions.txt); caption=${caption#*    }
564         else
565                 caption=""
566         fi
567         
568         $BPGALLERY_PAGE_FUNCTION > "${PAGESDIRECTORY}$currentpage"
569 }
570
571 if [[ $OUTPUTHTML != 0 ]]; then
572         $ECHOCOMMAND "<pre>"
573 fi
574
575 if [[ -z $1 ]]; then
576         $ECHOCOMMAND "No path given"
577         usage
578         exit 1
579 fi
580
581 if [[ "$1" == "--help" || "$1" == "-h" ]]; then
582         usage
583         exit 0
584 fi
585
586 if [[ "$1" == "--version" || "$1" == "-v" ]]; then
587         version
588         exit 0
589 fi
590
591 if [[ ! -d $1 ]]; then
592         $ECHOCOMMAND "$1 is not a directory"
593         usage
594         exit 2
595 fi
596
597 cd "$1"
598
599 if ( ! $FINDCOMMAND . $FINDIMAGESOPTIONS > /dev/null 2>/dev/null ); then
600         $ECHOCOMMAND "$1 does not contain any images. Quitting."
601         exit 4
602 fi
603
604 if [ ! -w . ]; then
605         $ECHOCOMMAND "Can't write to images directory, exiting"
606         exit 8
607 fi
608
609 if [ -e ${INDEXDOCUMENT} ] && [ ! -w ${INDEXDOCUMENT} ]; then
610         $ECHOCOMMAND "Can't write ${INDEXDOCUMENT}, exiting"
611         exit 8
612 fi
613
614 if [ -e style.css ] && [ ! -w style.css ]; then
615         $ECHOCOMMAND "Can't write style.css, exiting"
616         exit 8
617 fi
618
619 generate_thumbs
620
621 if [[ "x$PAGESDIRECTORY" != "x" ]]; then
622         if [ ! -d $PAGESDIRECTORY ]; then
623                 mkdir -p $PAGESDIRECTORY
624         fi
625
626         if [ ! -w $PAGESDIRECTORY ]; then
627                 $ECHOCOMMAND "Can't write to $PAGESDIRECTORY directory, exiting"
628                 exit 16
629         fi
630
631         BASEURL="../"
632 fi
633
634 if [ $GENERATEPAGESFORMEDIUMSIZE != 0 ]; then
635         generate_medium
636         generate_medium_pages
637 fi
638
639 if [ $GENERATEPAGESFORFULLSIZE != 0 ]; then
640         if [ $GENERATEPAGESFORMEDIUMSIZE != 0 ]; then
641                 generate_pages __medium
642         else
643                 generate_pages
644         fi
645 fi
646
647 if [ -r description.txt ] ; then
648         DESCRIPTION=$($SEDCOMMAND -e '1 { s/^/<p>/; }; /^$/ { s,$,</p><p>,; }; $ { s,$,</p>, };' description.txt)
649 else
650         DESCRIPTION=""
651 fi
652
653 BASEURL=""
654
655 $ECHOCOMMAND "Starting to generate page"
656
657 $BPGALLERY_HEAD_FUNCTION > ${INDEXDOCUMENT}
658 $BPGALLERY_DESCRIPTION_FUNCTION >> ${INDEXDOCUMENT}
659
660 $ECHOCOMMAND "Adding Captions"
661
662 extra=""
663 if [ $GENERATEPAGESFORMEDIUMSIZE != 0 ]; then
664         extra=__medium
665 fi
666
667 $FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 -I {} $ECHOCOMMAND {} | $SORTCOMMAND -g | while read filename; do filename=${filename#./}; if [ -r captions.txt ]; then caption=$($GREPCOMMAND -E "^$filename      " captions.txt); caption=${caption#*    }; else caption=""; fi; if [ $GENERATEPAGESFORMEDIUMSIZE != 0 ]; then link=${PAGESDIRECTORY}$(bpgallery_escape_url "${filename}${extra}.html"); elif [ $GENERATEPAGESFORFULLSIZE != 0 ]; then link=${PAGESDIRECTORY}$(bpgallery_escape_url "${filename}.html"); else link=$(bpgallery_escape_url "$filename"); fi; filename=$(bpgallery_escape_url "$filename"); $BPGALLERY_THUMBSLINE_FUNCTION; done >> ${INDEXDOCUMENT}
668
669 $BPGALLERY_TAIL_FUNCTION >> ${INDEXDOCUMENT}
670
671 $ECHOCOMMAND "Finished generating the page"
672 $ECHOCOMMAND "Generating stylesheet"
673 cd icons
674
675 MAXHEIGHT=$($FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 $IDENTIFYCOMMAND -format "%h\n" | $GREPCOMMAND -v "^$" | $SORTCOMMAND -g -r | $HEADCOMMAND -n 1)
676 MAXWIDTH=$($FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 $IDENTIFYCOMMAND -format "%w\n" | $GREPCOMMAND -v "^$" | $SORTCOMMAND -g -r | $HEADCOMMAND -n 1)
677
678 cd ..
679
680 # add a bit to the maxheight for the size of the caption
681 MAXHEIGHT=$((MAXHEIGHT+$CAPTIONHEIGHT))
682
683 $BPGALLERY_STYLESHEET_FUNCTION > style.css
684
685 $ECHOCOMMAND "All done"
686
687 if [[ $OUTPUTHTML != 0 ]]; then
688         $ECHOCOMMAND "</pre>"
689 fi