question about colors
Posted: 2009-07-30T07:34:31-07:00
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?
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.
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;
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.