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

foreach my $file(@ARGV) {
    
    my $image = Image::Magick->new();
    
    my $w = $image->Read($file);
    warn $w if $w;
    
    my @px = map($_ * 255, 
		 $image->GetPixels(height=>1, width=>1, normalize=>'true'));
    my $color = "rgb($px[0],$px[1],$px[2])";
    print "Converted $color to transparent.\n";
    
    $w = $image->Transparent(color=>$color);
    warn $w if $w;
    
    $w = $image->Write($file);
    warn $w if $w;

    undef $image;
}
