#!/usr/local/bin/perl # thumb 0.22 # created by: anders wisch # modified by: matt hine use Image::Magick; use POSIX qw( ceil ); # usage information. $usage = "usage: thumb [-hrti] [directory]\n"; # help information. $help = ""; $help = join '', $help, "usage: thumb [-hrti] [directory]\n"; $help = join '', $help, "\n"; $help = join '', $help, " -h (display this help message)\n"; $help = join '', $help, " -r (recurse through directories, starting with . -- currently broken)\n"; $help = join '', $help, " -i (generate indexes only)\n"; $help = join '', $help, " -t (generate thumbnails only)\n"; $help = join '', $help, "\n"; $help = join '', $help, "\n"; $help = join '', $help, "in template.html for each thumbnail directory/page:\n"; $help = join '', $help, "\n"; $help = join '', $help, "\n"; $help = join '', $help, "\n"; # flags are assigned default values. $indexonly = 0; $thumbnailsonly = 0; $recursive = 0; # default root directory (wherever the script was called). $root = '.'; # parse the command line arguments. die $usage if ( @ARGV > 3 ); foreach (@ARGV) { if ( /^-/ ) { for( split //, $' ) { if ( /h/ ) { die $help; } elsif ( /i/ ) { $indexonly = 1; next; } elsif ( /t/ ) { $thumbnailsonly = 1; next; } elsif ( /r/ ) { $recursive = 1; next; } else { die $usage; } } } else { $root = $_; die $usage if ( not -e $root ); } } die "-i and -t may not be simultaneously selected.\n" if ( $indexonly and $thumbnailsonly ); # call our process method on the root directory. process( $root ); sub process { my $path = shift; my $template; my $indexname = 'index.html'; my $suffix = '_'; my $viewsuffix = '-'; my $target = '_parent'; my $thumbnailwidth; my $thumbnailheight; my $pixelarea; my $thumbnailscale; my $cellpadding = 10; my $thumbnailborder = 5; my $columns = 5; # read in the template. print "reading in $path/template.html\n"; open TEMPLATE, "$path/template.html" or die "template.html not found in $path.\n"; my $template = join '',