#!/usr/bin/perl -w #--------------------------------------------------------# # This script makes an html page of all pictures # # found in the FVTX directory tree, and # # - makes a thumbnail, # # - a clickable reference to the picture, # # - references to web pages where the picture is used # # # # September 2011 Hubert van Hecke # # # #--------------------------------------------------------# use File::stat; use Time::localtime; open FILE, ">all_pics.html"; # output file, print HTML header etc: print FILE (" all fvtx pictures
FVTX pictures


This page was produced by running this Perl script.



Thumbnail Full path (starting at ...WWW/fvtx/) Used in page: "); $command = "rm *_thumb.jpg"; # get rid of the old thumbnails system($command); # # list of picture extensions: @exts = ("jpg","JPG","jpeg","JPEG","png","gif","GIF"); $nexts = scalar(@exts); # array length #$nexts = 1; # for short test runs for ($jex=0; $jex<$nexts; $jex++) { # loop over icture types $nskip = 0; # counters for $skip = 0; # quick tests # grab al list of files: $command = "find ../ -name \"*.$exts[$jex]\" |"; open GRAB, $command; # while () { # loop over all files of this type if ($skip==0) { # this is for bailing out early #if ($nskip>5) { $skip=1 } # activate for test $fullname = $_; # full name, includes $fullname =~ s/\s+$//; # remove trailing spaces print (" SEEN: $fullname \n"); if (index($fullname,"all_pics")<1 && # avoid self-reference index($fullname,"no_thumb")<1) { # too many references to this jpg $nskip++; # bailout counter $thumb = $fullname; # make name for thumb $i = 1; # Skip forward to the last '/' while ($i) { # $i = index($thumb,"/") + 1; # find / $thumb = substr($thumb,$i); # remaining substring } # end search last / $thumb_jpg = $thumb; $thumb = substr($thumb,0,-4); # remove 3-letter extension $localname = $thumb."_thumb.jpg"; # add _thumb #print ("$fullname, $localname \n\n"); $fullesc = $fullname; # for use in 'command', $fullesc =~ s/ /\\ /g; # escape spaces in the file name $localesc = $localname; # same for localname $localesc =~ s/ /\\ /g; # $command = "convert ".$fullesc." -format jpg -thumbnail 100x100 ".$localesc; #print ("$command \n"); system($command); # produce the thumbnail # add this picture to the table: print FILE ("
  $fullname "); # search for files where this picture is used: $command = "find ../ -name \'*.html\' -exec grep -H \'$thumb_jpg\' {} \\; |"; #print ("command: $command \n"); $nlinks = 0; open USEDIN, $command; # get the list of references while () { # loop over references $nlinks++; # count them $path = $_; $j = index($path,":"); # remove everything past the ":" $path = substr($path,0,$j); # if (index($path,"all_pics")<0) { # avoid self-reference #print ("PATH: $path \n"); print FILE (" $path
"); } # exclude self-reference to all_pics } # loop over links close USEDIN; # none found: if ($nlinks<=1) { print FILE ("  (not used)"); } print FILE (" "); # 'not used' test fails for duplicate names } # no self-reference } # no skip (test only) } # while grab - main loop over found files close GRAB; #print ("finished with GRAB\n"); } # loop over file types # finish the HTML code: print FILE ("
"); # close FILE; # close html