#!/usr/bin/perl # =head1 NAME phogal.pl =head1 AUTHOR Matteo Redaelli E-MAIL: matteo.redaelli@libero.it WEB: http://digilander.iol.it/reda =head1 DESCRIPTION This is a nice and innovative photo gallery generator: it doesn't create any thumbnails but it reduce the size of the original pictures and insert them in several web pages with fortune cookies (provided by the command "fortune"). Than you can replace them inserting your personal comments/descriptions of the pictures.. =head1 USAGE type perl phogal.pl =head1 REQUIREMENTS perl interpreter (www.perl.org) ImageMagick (http://www.imagemagick.org) forture package =head1 HISTORY 2002-03-10: first lines of this script 2002-03-11: added "fortune" support: afterward you can replace cookies with your favourite comment =head1 LICENSE This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License". =head1 DISCLAIMER This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "GNU General Public License" for more details. =cut use Getopt::Std; use strict; my $dest_dir = $ARGV[0]; my $label = $dest_dir; $label =~ s/_/ /g; my $step = 5; my @files = <*.jpg *.JPG>; my $menu; sub build_menu { my $result = ""; for my $c (0 .. int( $#files / $step ) ) { $c = "" if $c == 0; $result = $result . "index$c "; } return $result; } sub openhtmlfile { my $c = int(@_[0] / $step) ; $c = "" if $c == 0; open STDOUT, ">$dest_dir/index$c.html"; print < $label
$menu

$label

EOC } sub closehtmlfile { print < EOC # close STDOUT; } sub odd { return ( @_[0] % 2 ) ? 0 : 1; } sub print_row { my $filename = @_[0]; my $cont = @_[1]; print "\n"; print "\n"; print "\n"; print "\n"; } $menu = build_menu(); my $cont = 0; mkdir "$dest_dir"; openhtmlfile( $cont ); foreach my $file ( @files ) { if ( $cont != 0 && $cont % $step == 0) { closehtmlfile(); openhtmlfile( $cont ); } system("convert -resize 350 -font helvetica -fill yellow -draw 'text 20,20 \"$label\"' $file $dest_dir/$file"); print_row( $file, $cont); ++$cont; } closehtmlfile();
\n"; odd( $cont) ? system("/usr/games/fortune") : print "\"$filename\"\n"; print "\n"; odd( $cont) ? print "\"$filename\"\n": system("/usr/games/fortune"); print "