On Fri, 6 Feb 2009 23:36:52 -0800
Dodger <[email protected]> wrote:

>Would there be any way to do this in the PerlMagick API, though?

I don't know if this will help, maybe you can do some
averaging on the values to get the same results as
Fred Weinhaus's shell method.

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

my $file = shift or die "Need a file $!\n";

my $img = Image::Magick->new;
$img->ReadImage($file);

my $tot = 0;
my (@colors) = $img->Histogram();

#print join "\n\n", @colors;

while (1){
     if (scalar @colors == 0){last}
     my $r = shift @colors;
     my $g = shift @colors;
     my $b = shift @colors;
     my $o = shift @colors;
     my $count = shift @colors; 
     $tot++;

        my $rh = sprintf('%02X',$r);
        my $gh = sprintf('%02X',$g);
        my $bh = sprintf('%02X',$b);

print "$count ($rh,$gh,$bh) at $o opacity\n"; 
}

print "\n$tot total colors\n";

__END__

HTH,
zentara

-- 
I'm not really a human, but I play one on earth.
http://www.zentara.net/~zentaran/Remember_How_Lucky_You_Are.html 
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to