palkia has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone

After I've got this annoying die message:
Can't locate object method "hsv" via package "Imager::Color"
and couldn't figure whats the problem I've copied the entire code example from cpan:
use Imager; $color = Imager::Color->new($red, $green, $blue); $color = Imager::Color->new($red, $green, $blue, $alpha); $color = Imager::Color->new("#C0C0FF"); # html color specification $color->set($red, $green, $blue); $color->set($red, $green, $blue, $alpha); $color->set("#C0C0FF"); # html color specification ($red, $green, $blue, $alpha) = $color->rgba(); @hsv = $color->hsv(); $color->info();
(from here)

but it died the same.
My "Imager" worked ok so far but it can't hsv() from some reason.
I've succesfuly used Imager::Color->new(...) etc before,
so it can't be the "Imager::Color" that's not installed or anything like that.

Any ideas ???
Thx

Replies are listed 'Best First'.
Re: Can't locate object method "hsv" via package "Imager::Color"
by wrog (Friar) on Dec 27, 2011 at 00:47 UTC

    Do you have the latest version?

    (Changes file says that hsv was added in 0.81 (Feb 2011) so if what you have installed predates that...)

      100 % right
      Thank you very much (I would've taken a very long time to think about something like that ^^)
Re: Can't locate object method "hsv" via package "Imager::Color"
by Khen1950fx (Canon) on Dec 27, 2011 at 04:44 UTC
    I ran your example and encountered the same problem. I finally had to break it up a little and did this:
    #!/usr/bin/perl use strict; use warnings; use Imager qw(:all); use Imager::Color; use Imager::Color::Table; use Data::Dump qw(dump); use Term::ANSIColor::Print; my $print = Term::ANSIColor::Print->new(); $print->black("=" x 15); $print->dark_green("Color Table: "); $print->black("=" x 15); my @rgb = Imager::Color::Table->get('red'); $print->dark_red("red is ", @rgb); @rgb = Imager::Color::Table->get('green'); $print->dark_green("green is ", @rgb); @rgb = Imager::Color::Table->get('blue'); $print->dark_blue("blue is ", @rgb); $print->black("=" x 43); my $c1 = Imager::Color->new(255, 0, 0); my $c2 = Imager::Color->new(0, 255, 0); my $c3 = Imager::Color->new(0, 0, 255); my $c4 = Imager::Color->new( xsize => 5, ysize => 15, ); $print->dark_red("The first channel hsv is: ", dump my @hsv1 = $c1->hsv()); $print->dark_green("The second channel hsv is: ", dump my @hsv2 = $c2->hsv()); $print->dark_blue("The third channel hsv is: ", dump my @hsv3 = $c3->hsv()); $print->black("=" x 43); $print->dark_magenta("The rgba is: "); $print->dark_red("r: ", dump $c1->rgba()); $print->dark_green("g: ", dump $c2->rgba()); $print->dark_blue("b: ", dump$c3->rgba());