[PerlMagick] SetPixel not properly setting RGB value

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
SeanP

[PerlMagick] SetPixel not properly setting RGB value

Post 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: Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: [PerlMagick] SetPixel not properly setting RGB value

Post by magick »

We can reproduce the problem you reported and will have a patch by tomorrow. Thanks.
SeanP

Re: [PerlMagick] SetPixel not properly setting RGB value

Post by SeanP »

Thanks magick for the fast reply and fast fix. Looks like version 6.4.8-4 resolves the issue.

Thanks again!
gregaiken
Posts: 14
Joined: 2011-07-21T16:31:23-07:00
Authentication code: 8675308

Re: [PerlMagick] SetPixel not properly setting RGB value

Post 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?
mtulio2
Posts: 1
Joined: 2017-11-12T16:40:36-07:00
Authentication code: 1152

Re: [PerlMagick] SetPixel not properly setting RGB value

Post 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.
Post Reply