#!/usr/bin/perl
# resize to 160 on the long edge and add black border

use Image::Magick;

$source_dir = shift || ".";

my @allFiles;    
opendir DIR, $source_dir;
@allFiles = grep !/^\./, readdir DIR;
closedir DIR;

foreach $file (@allFiles)
{
    if ($file =~ m/^b.*?\.jpg/g)
    {
	print "$file\n";
	$image = Image::Magick->new;
	$image->Read("$source_dir/${file}");
	$image->Resize(geometry=>"160x160");
	$image->Border(geometry=>"2x2", fill=>"black");
	$image->Write(filename=>"$source_dir/t_${file}", quality=>'75');
	undef $image;
    }
}
