#!/usr/bin/perl -w
use strict;
use Image::Magick;


opendir ORIG, "orig" or die $!;
while( my $file = readdir( ORIG ) )
{
    next if $file =~ /^\./;
    print $file . "\n";

    $file =~ /(.*)\.jpg/i or next;
    my $name = $1;

    my $p = new Image::Magick;
    $p->Read("orig/$file");

    my $x = $p->Get('width');
    my $y = $p->Get('height');

    $p->Write(filename=>"img/${name}.jpg", quality=>60 );

    my $xt = 300;
    my $yt = int( $xt * $y / $x );

    $p->Thumbnail(width=>$xt, height=>$yt);

    print "  Saving $name\n";
    $p->Write(filename=>"img/${name}-t.jpg", quality=>30 );
}
