....Is there a library ...The Image Magick library does it all, and it has a Perl interface.... see perl magick usage
Here is a simple usage of IM, to list all pixels,.... just in case you want to test just one certain pixel. :-)
#!/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);
# if you want a pixel by pixel list of every color
# a huge slow output
$img->Set(magick => 'txt');
$img->Write("$0.txt");
##################################################
#histogram
#returned values are an array of
#red, green, blue, opacity, and count values.
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++;
print "$count ($r,$g,$b) at $o opacity\n";
}
print "\n$tot total colors\n";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|