#! /usr/local/bin/perl

# 6.837
# Created by Justin Legakis (legakis@graphics.lcs.mit.edu) for Fall 1996

require "ctime.pl";


$update = &ctime(time);

# Create thumbnail versions of all pictures in a directory.
# Requires the executable "thumbnailer."

$picpath="/pub/www/6.837/f96/pictures_tmp";
$thumbpath="/pub/www/6.837/f96/thumbnails";
$scriptspath="/pub/www/6.837/f96/scripts";


opendir(THISDIR, $picpath);
@allfiles = grep(/^.*\.gif$/, readdir(THISDIR));
closedir(THISDIR);


foreach $file (@allfiles) {
 $thumbtitle = $file;
 $thumbtitle =~ s/.gif/_small.gif/g;

 if (!-e "$thumbpath/$thumbtitle") {

     print "$file  ->  $thumbtitle\n";

     system("$scriptspath/thumbnailer $picpath/$file $thumbpath/$thumbtitle -s 96 -b 1 -c\n");

	chmod 0644, "$thumbpath/$thumbtitle"

 }
}

