Page 1 of 1
[PerlMagick] SetPixel not properly setting RGB value
Posted: 2009-01-09T14:30:34-07:00
by SeanP
Just installed ImageMagick on my Kubuntu 8.04 system with mostly default options (configured with --disable-openmp). When attempting to use SetPixel in PerlMagick to set an RGB triple, the blue value is not set. The code below should yield a small black square with a white pixel in the center, but instead yields a black square with a yellow pixel in the center.
I'm rather at a loss for what might be causing this... any ideas?
Code: Select all
#!/usr/bin/perl -w
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'3x3');
$image->ReadImage('xc:black');
@pixels = $image->GetPixel(x=>1,y=>1);
foreach $pixel (@pixels) {
$pixel = 1;
}
print "@pixels \n"; # This shows all three values in @pixels are 1
$image->SetPixel(x=>1,y=>1,color=>\@pixels);
$image->Write('foo.png');
Resultant image:
Re: [PerlMagick] SetPixel not properly setting RGB value
Posted: 2009-01-09T22:08:52-07:00
by magick
We can reproduce the problem you reported and will have a patch by tomorrow. Thanks.
Re: [PerlMagick] SetPixel not properly setting RGB value
Posted: 2009-01-10T12:57:34-07:00
by SeanP
Thanks magick for the fast reply and fast fix. Looks like version 6.4.8-4 resolves the issue.
Thanks again!
Re: [PerlMagick] SetPixel not properly setting RGB value
Posted: 2014-04-02T10:09:18-07:00
by gregaiken
i am using a newer version if ImageMagick 6.8.6-Q16 Windows x86 build - and this same problem persists.
ive been hoping for a long while to finally get to use ImageMagick with ActivePerl.
i finally have this configured and am rather unhappy to discover i also can not reliably set pixel values within an image.
my hope was to use this to create images from scratch for scientific visualization.
when i try the following code...
use Image::Magick; #version 6.8.6 Q16 windows x86 build
$im=Image::Magick->new;
$im->Set(size=>'5x4');
$im->ReadImage('canvas:red');
$im->SetPixel(x=>0,y=>0,color=>[0,0,0]);
$im->SetPixel(x=>1,y=>1,color=>[50,50,50]);
$im->SetPixel(x=>2,y=>2,color=>[100,100,100]);
$im->SetPixel(x=>3,y=>3,color=>[150,150,150]);
$im->SetPixel(x=>4,y=>4,color=>[200,200,200]);
$im->Write(filename=>'out.png', compress=>'None');
#pixel 0,0 is black [0,0,0]
#pixels 1,1 and 2,2 and 3,3 and 4,4 are white [255,255,255]
#it behaves as though each pixel may only contain value 0 or 255 for each of the color tuples
#intermediate values seem to be coerced by ImageMagick to clamp to either value 0 or value 255.
any specific suggestions as to how i can get this feature to work properly with ActivePerl (v5.16.1) built for MSWin32-x86-multi-thread?
Re: [PerlMagick] SetPixel not properly setting RGB value
Posted: 2017-11-12T17:00:16-07:00
by mtulio2
I'm using PerlMagick version 7.0.4-0 and still having this problem. Anyone knows if it was fixed only on version 6.4.8-4? Is there any way to fix it in my local installed version of PerlMagic? Thanks.