# # all.pl - process digital pictures into thumbnails and framesets # Copyright (C) 2002 - Anthony Tonns # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # --- # # ATonns Tue Jun 18 23:40:00 EST 2002 # do all image processing # # ATonns Sat Jul 27 09:48:00 EST 2002 # made more Win32/UNIX portable # # what all.pl does: # # 0) place all photos in a single directory (c:\pics\YYYYMMDD) # # 1) all.pl will create subdirs: # c:\pics\YYYYMMDD\raw # c:\pics\YYYYMMDD\images # c:\pics\YYYYMMDD\thumbnails # c:\pics\YYYYMMDD\html # # 2.1) all.pl will $copy all pics into images # 2.2) all.pl will $move all pics into raw # # 3.1) all.pl will $mogrify all pics in images to $image_size # 3.2) all.pl will $copy resized pics into thumbs # # 4) all.pl will $mogrify all pics in thumbs to $thumb_size # # 5) all.pl will create HTML files (in html dir) for each pic # and generate left.html with preview of each thumb # # 6) all.pl will $copy ../template_index.html to index.html # 7) all.pl will $copy ../template_right.html to right.html # use strict; use Image::Size; # program names, etc. for Win32/UNIX portability my $mogrify="C:\\progra~1\\ImageMagick\\mogrify.exe"; my $copy = "copy"; my $move = "move"; my $dirsep = "\\"; my $ext = "JPG"; my $prev_index = "index.html"; # size to create images for viewing my $image_width = "640"; my $image_height = "480"; my $image_size = "${image_width}x${image_height}"; # size to create thumbnails for previewing my $thumb_width = "128"; my $thumb_height = "128"; my $thumb_size = "${thumb_width}x${thumb_height}"; # simple subroutine to execute system calls (or easily not run them) sub runme { my $runme=join(" ",@_); print "$runme\n"; system("$runme"); } # create all the necessary directories runme("mkdir raw"); runme("mkdir images"); runme("mkdir html"); runme("mkdir thumbnails"); # get a list of image files (ONLY! no movies here) my @files = glob "*.$ext"; # copy them into the images directory for processing and... # then move them into the raw directory for archiving foreach (@files) { my $file = $_; runme(qq!$copy "$file" images!); runme(qq!$move "$file" raw!); } # reduce all images in the images directory for viewing and... # copy them into the thumbnails directory for processing chdir "images"; foreach (@files) { my $file = $_; runme(qq!$mogrify -verbose -geometry $image_size "$file"!); runme(qq!$copy "$file" ..${dirsep}thumbnails!); } chdir ".."; # reduce all images in the thumbnails directory for previewing chdir "thumbnails"; foreach (@files) { my $file = $_; runme(qq!$mogrify -verbose -geometry $thumb_size "$file"!); } chdir ".."; # create the thumnail nav bar (L) my $prevname = ""; open(L,">left.html"); print L qq!\n!; print L qq!\n!; print L qq!left\n!; print L qq!\n!; print L qq!\n!; print L qq!\[Up\]
\n!; while ($#files >= 0 ) { my $file = shift(@files); my ($thisname,$ext1) = split(/\./,$file); my $next = $files[0]; my ($nextname,$ext2) = split(/\./,$next); print qq!"$thisname" -> "$prevname" and "$nextname"\n!; # create the page the image is viewed on open (F,">html/$thisname.html"); print F qq!\n!; print F qq!\n!; print F qq!$thisname\n!; print F qq!\n!; print F qq!\n!; # since the navigation string is both at the top and bottom, # just store it in a variable now for dual usage later my $navstring = ""; # if there's a previous, make it a link $navstring .= qq!\[!; if ( $prevname ne "" ) { $navstring .= qq!!; } $navstring .= qq!Prev!; if ( $prevname ne "" ) { $navstring .= qq!!; } $navstring .= qq!\] !; # go up to main page $navstring .= qq!\[Up\]!; # view the raw photo $navstring .= qq!\[Raw\]!; # if there's a next make it a link $navstring .= qq!\[!; if ( $nextname ne "" ) { $navstring .= qq!!; } $navstring .= qq!Next!; if ( $nextname ne "" ) { $navstring .= qq!!; } $navstring .= qq!\] !; $navstring .= qq!
!; # print the guts of the page print F qq!$navstring\n!; # if there's a next, make it a link if ( $nextname ne "" ) { print F qq!!; } my($width,$height) = imgsize("images/$file"); print F qq!!; if ( $nextname ne "" ) { print F qq!!; } print F qq!
\n!; print F qq!$navstring\n!; print F qq!\n!; print F qq!\n!; close F; print L qq!!; my($thumbwidth,$thumbheight) = imgsize("thumbnails/$file"); print L qq!
\n!; $prevname = $thisname; } print L qq!\[Up\]
\n!; print L qq!\n!; print L qq!\n!; close L; runme(qq!$copy ..${dirsep}template_index.html index.html!); runme(qq!$copy ..${dirsep}template_right.html right.html!);