edgar@cgn:~$ vi mk_gallery.sh
<HighlightSyntax>
- !/bin/bash
- create image gallery for Edgar
- make thumbs
for file in ~/public_html/images/*
do convert -size 100 $file ~/public_html/images/thumbs/th-`basename $file`
done
- make html
php /home/edgar/mk_gallery.php > /home/edgar/public_html/index.html
</HighlightSyntax>
edgar@cgn:~$ vi mk_gallery.php
<HighlightSyntax> <?php
- Make the gallery html for Edgar's image dump
- mutante / s23
- Pathes to images, thumbnails and the html to be generated
$image_dir="/home/edgar/public_html/images"; $thumbs_dir="/home/edgar/public_html/thumbs"; $html_file="/home/edgar/public_html/index.html";
- Create a html gallery
function mkgallery($image_dir,$thumbs_dir,$html_dir) {
- HTML Header
$html_head = <<< FNORD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head><title>Edgar's image gallery</title> <meta name="author" content="S23" /> </head> <body> FNORD;
- HTML Footer
$html_foot = <<< FNORD
Generated by FnordGallery V2.3
</body> </html> FNORD;
- HTML Body loop
foreach (glob("$image_dir/*") as $filename) { $basename=basename($filename);
$html_body.="
<a href=\"./images/$basename\"><img src=\"./images/thumbs/th-$basename\" alt=\"$basename thumbnail\"></img></a> $basename - size ". filesize($filename) ." B
\n";
}
- Give it back!
$html_output=$html_head.$html_body.$html_foot; return $html_output; }
- Do it!
print mkgallery($image_dir,$thumbs_dir,$html_dir);
?> </HighlightSyntax>
edgar@cgn:~$ ./mk_gallery.sh
(valid)