#!/usr/bin/perl
# thumbnail.pl, copyright Casey Muller
# a somewhat specialized image thumbnailing script
use POSIX;
$topdir = "/usr/media/images/digitalcamera/";
$tagdir = "/usr/media/images/tags/";
$recentfile = "/usr/media/web/generate/recentPhotos";
$locationmapfile = "/usr/media/web/generate/root/null-terminated/visuals/photography/map/map.rss";
$locationtripfile = "/usr/media/web/generate/root/null-terminated/visuals/photography/map/trip.rss";
$datelocfile = "/usr/media/images/dateloc";
$currentloc = "";
$locstarted = "present";
$prefix = "http://images.null-terminated.com/";
$encodedprefix = "http%3A%2F%2Fimages.null-terminated.com%2Fdigitalcamera%2F";
$formdir = "http://home.null-terminated.com:81/cgi-bin/";
$tagform = $formdir."suggesttag.pl";
$multitagform = $formdir."multitagsug.pl";
$thumbpath = "/visuals/photography/by-date/";
$thumbprefix = "http://null-terminated.com".$thumbpath;
$tagpath = "/visuals/photography/tags/";
$tagprefix = "http://null-terminated.com".$tagpath;
$imageproc = "-normalize -unsharp 3";
$sizes{"tiny"} = "-size 36x24 -resize 36x24 +profile \"*\" $imageproc";
#$sizes{"tiny"} = "-size 48x32 -resize 48x32 +profile \"*\" $imageproc";
$sizes{"thumb"} = "-size 320x240 -resize 320x240 +profile \"*\" $imageproc";
#$sizes{"thumb"} = "-size 480x320 -resize 480x320 +profile \"*\" $imageproc";
$sizes{"medium"} = "-size 1024x1200 -resize 1024x1200";
# load the location mappings
require 'encodedlocs.pl';
# open recent file
open(RECENT, '>', $recentfile);
# open date location file
open(DATELOC, '>', $datelocfile);
# open the main index
open(HTML, '>', $topdir."contactsheet.html");
print HTML <
Once the images have loaded, mousing over them should reveal a larger thumbnail.
HEADER
$today = strftime "%Y-%m-%dT%H:%M:%SZ", gmtime();
open(RSS, '>', $topdir."allphotos.rss");
#open(RSS, '>', $topdir."photos.rss");
$photocount = 0;
$datecount = 0;
print RSS <
null-terminated photography
$today
Casey Muller
atomfeed\@nullterminated.com
RSSHEADER
system("cp", $topdir."allphotos.rss", $locationmapfile);
system("cp", $topdir."allphotos.rss", $locationtripfile);
system("cp", $topdir."allphotos.rss", $topdir."allphotodates.rss");
open(DATERSS, '>>', $topdir."allphotodates.rss");
use File::Find;
use Image::EXIF;
$exif = new Image::EXIF;
find { preprocess => sub {
# calculate the path
$dir = substr $File::Find::dir, length($topdir);
print HTML "$prefix$dir
\n";
# open the directory-level html file
if($dir =~ /_\d\d$/) {
print "checking $File::Find::dir\n";
open(DIR, '>', "$File::Find::dir/index.html");
print DIR "\n";
close SMALLRSS;
}
}
}, postprocess => sub {
close DIR;
print DATERSS <See all photos from this day
]]>
RSSBLOCK
if($datecount++ == 20) {
system("cp", $topdir."allphotodates.rss", $topdir."photodates.rss");
open(SMALLDATERSS, '>>', $topdir."photodates.rss");
print SMALLDATERSS "\n";
close SMALLDATERSS;
}
}}, $topdir;
close HTML;
print RSS "\n";
close RSS;
print DATERSS "\n";
close DATERSS;
open(TAGS, '>', $tagdir."index.html");
print TAGS "Content tags:\n";
foreach(keys %tagfiles) {
if(!exists $techtags{$_}) {
if($tagcount{$_} > $maxtagcount) {
$maxtagcount = $tagcount{$_};
}
if($tagcount{$_} < $mintagcount) {
$mintagcount = $tagcount{$_};
}
}
}
foreach(sort keys %tagfiles) {
($safetag = $_) =~ s#/#-#g;
# size is 0 to 1
$size = ($tagcount{$_} - $mintagcount) / ($maxtagcount - $mintagcount);
# interpolate
$fontsize = $size * 36 + 9;
$imagesize = int($size * 12 + 12);
$taghtml = "
$_($tagcount{$_}) \n";
print "last: $lastpicture{$_}\n";
if(exists $techtags{$_}) {
print "tech ";
$techhtml .= $taghtml;
} else {
print TAGS $taghtml;
}
print "$_ = $tagcount{$_}\n";
close $tagfiles{$_};
}
# open location files
open(MAPRSS, '>>', $locationmapfile);
# write the locationsf
foreach(sort keys %locationlist) {
print MAPRSS <
$_
$_
$today
$today
$locationtag{$_}
RSSBLOCK
}
# footer
print MAPRSS "\n";
close MAPRSS;
print TAGS "\n\nOr look at the technical tags.\n";
close TAGS;
open(TAGS, '>', $tagdir."technicaltags.html");
print TAGS "\n\nTechnical tags:\n$techhtml";
close TAGS;
open(TRIPRSS, '>>', $locationtripfile);
for($i=0; $i<$#mapcoords; $i++) {
print TRIPRSS <
$mapcoords[$i] to $mapcoords[$i+1]
$mapcoords[$i]
$today
$today
$locationtag{$mapcoords[$i]} $locationtag{$mapcoords[$i+1]}
RSSBLOCK
}
print TRIPRSS "\n";
close TRIPRSS;