I have a 4x1 pixel PNG where the left pixel is white (#ffffff), the second pixel red (#FF0000),
The third pixel is green (# 00FFF) and the most pixel blue (# 0000ff) is almost invisible here: .
With the following Perl script, I tried to read RGB values for each pixel:
Use warnings; Strict use; Use GD; My $ image = new GD :: image ('white-red-green-blue' '') or die; (My $ x = 0; $ x
My surprise The thing is, it is printed
252 254 252 252 2 4 4 254 4 4 2 252
While I was expecting
255 255 255 255 0 0 255 0 0 255
Why the script report incorrect RGB values and how can I mpapec according to the question Edit Of Bluekpng base64 of white-red-green color production
is
iVBORw0KGgoAAAANSUhEUgAAAAQAAAABCAIAAAB2XpiaAAAAAXNSR0IArs4c6QAAAARnQU1B AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASSURBVBhXY / gPBAwMDEDM8B8AL90F + 8V5iZQAAAAASUVORK5CYII =
Edit II According to the suggestion of Dgw , I also tried to Update with the same result: I my $ image = newFromPng GD :: image ('white-red-green-blue') or die;
Image :: Magick
instead of GD
:
use warnings; Strict use; Image :: Use Magick; My $ image = image :: Magick-> new or die; My $ reading = $ image - & gt; Read ('white-red-green-blue.png'); (My $ x = 0; $ x <4; $ x ++) {my @ pixels = $ image- & gt; GetPixels (width => 1, height = & gt; 1, x => $ x, y = & gt; 0, map = & gt; 'RGB', #normalize = & gt; 1); Printf "% 3d% 3d% 3d \ n", $ pixel [0] / 256, $ pixel [1] / 256, $ pixel [2] / 256; }
And, to some extent unsurpringly, this hope print
<255 255 255 255 0 255 0 0 255
UPDATED
OK, fix it with your image Works if you do this:
GD :: image-> True color (1);
Before starting anything with the GD, I think this is because one image has been printed and the other is not. See here:
Original Answer
This works fine on my iMac. I have generated this image with ImageMagick:
Convert-size 1x1! Xc: rgb \ (255,255,255 \) axis: rgb \ (255,0,0 \) axis: rgb \ (0,255,0 \) axis: rgb \ (0,0,255 \) + epand wrgb.png./go.pl 255 255 255 255 0 0 255 0 0 255
I suspect that your image is not being produced properly.
Comments
Post a Comment