#!/usr/bin/perl # Philip Shuman philip at shuman dot org # album.pl v0.2.1 # web photo album index.html generator and photo resizer # # requires ImageMagick's `mogrify` utility, # Image::Size from http://www.blackperl.com/Image::Size/ # and Getopt::Std. # # Usage: # cd into the directory with your .jpg files. # run album.pl # give it the -g 640x480,800x600,1024x768 to create different # scaled images. (without -g will default to 640x480,1024x768) # # Change this to your email, name, etc. $comment = "youremail\@shuman.org"; use Image::Size; use Getopt::Std; if (getopts("g:")) { } else { exit -1; } if (!$opt_g) { @geos = ('640x480', '1024x768'); print "no -g, defaulting to 640x480,1024x768\n"; } else { @geos = split(',', $opt_g); } @files = `/bin/ls -1 *.jpg`; `echo "" > index.html`; `echo "" >> index.html`; $index = 0; foreach $file ( @files ) { chomp($file); ($x, $y) = imgsize("$file"); $orgsize = "$x" . "x$y"; print "$file $x" . "x$y\n"; $tmp = $file; $tmp =~ s/\.jpg/_thm.jpg/; print " Creating $tmp\n"; `cp $file $tmp`; `/usr/local/bin/mogrify -geometry 128x96 -quality 60 $tmp`; `echo " " >> index.html`; $index++; if ($index >= 6) { `echo "" >> index.html`; $index=0; } } `echo "
" >> index.html`; `echo "
" >> index.html`; foreach $res (@geos) { $tmp = $file; $tmp =~ s/\.jpg/_$res.jpg/; print " Creating $tmp\n"; `cp $file $tmp`; `/usr/local/bin/mogrify -comment "$comment" -geometry $res -quality 70 $tmp `; `echo " $res
" >> index.html`; } `echo " $orgsize" >> index.html`; `echo "
" >> index.html`;