use Image::Size;

my $fname = "JPGfilelist.txt";

open (IN, $fname) || die "can't open $fname\n";

my $settitle;

while (<IN>) {
    chomp;
    next if /^#/;
    my $picname = $_;
    make_resize($picname);

}

#### making thumbnails thingies wheeee
sub make_resize {

    my $picname = shift;
    my $picroot = $picname;
    $picroot =~ s/\.JPG//i;
    $picroot =~ s/^0//i;

    my ($width, $height) = imgsize($picname);
    return unless $width;
    print "making thumbnail for $width x $height $picname\n";
    my $thumbheight, $thumbwidth;
    if ($width > $height) {
	$thumbwidth = 600;
	$thumbheight = (600 * $height) / $width;
    }
    else {
	$thumbheight = 600;
	$thumbwidth = int ((600 * $width) / $height);
    }
    my $thumbname = "$picroot.jpg";

    system "cp $picname $thumbname";
    system "mogrify -resize ${thumbwidth}x$thumbheight $thumbname";
}
