question about colors

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

question about colors

Post by ajfl »

Hi,

I'm just starting out with perlmagick and am having
some trouble getting it to display colors.

I was expecting this to show a black image with a
gradient line of blue pixels through the middle.
Can anyone please help me spot the error and
suggest a more efficient way to access colors as RGB values?

Code: Select all

#!/usr/bin/perl -w
use Image::Magick;

# Create a new image
my $image = new Image::Magick;
$image->Set(size => '600x600');
my $status = $image->Read(filename => 'xc:black');
warn "$status" if $status;

for($i=0;$i<255;$i++)
{
      $name = $image->QueryColorname('rgba(255,255,' . $i . ',0)');      
      $image->Set('pixel[' . $i . ',300]'=>$name);                                 
}   

$image->Write('jpeg:out.jpg');
undef $image;
The best get-me-started page I have found so far is:
http://www.imagemagick.org/script/perl-magick.php
Is there something else like this for the beginner that
goes into more detail?

Many Thanks,
Adrian.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: question about colors

Post by magick »

It looks like PerlMagick recognizes color names but not of the form rgba(). We will get a patch for the problem into the next point release. This is a work around for now:

Code: Select all

for($i=0;$i<255;$i++)
{
      $image->Set('pixel[' . $i . ',300]'=>'65535,65535,' . (257*$i));
}
Post Reply