Load Image Posterizing

[email protected] (Alex Dodge) Thu, 7 May 2009 00:23:56 -0700
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hello.  I am using GD 2.0.34 with Perl and am running into a snag.
Firstly, I hope this is the right forum for Perl questions.  I believe
my problem is with GD not Perl, but if this isn't the right venue, I'd
appreciate being redirected.

I'm trying to load an image and access the pixel data.  However, I'm
noticing that GD seems to be posterizing the image when I load it, so
I'm not getting all the colors.  I suspect I'm doing something wrong.

Attached is a perl script that shows the problem.  When I run it on,
for example, this image:
http://upload.wikimedia.org/wikipedia/commons/4/4a/Colorful_pottery.jpg

I get this:

$ ./imgavg.pl Colorful_pottery.jpg
202 colors.

I'm fairly certain that that image has more than 202 colors, so I'm
wondering where I'm going wrong.  Any help would be appreciated.

Thank you very much.

Alex Dodge
http://alexdodge.net/