The above suggest four elements are returned, but when I try it (on ImageMagick 7.0.7-15 Q16 x86_64 2018-01-17, Centos 6.9, perl v5.10.1), I get an error with those last two calls, i.e., when asking for four elements:Call QueryColor() with no parameters to return a list of known colors names or specify one or more color names to get these attributes: red, green, blue, and opacity value.
@colors = $image->QueryColor();
($red, $green, $blue, $opacity) = $image->QueryColor('cyan');
($red, $green, $blue, $opacity) = $image->QueryColor('#716bae');
Code: Select all
printf("red = %d, green = %d, blue = %d, opacity = %d\n", $red, $green, $blue, $opacity);
With the following, scalar(@colors) returns 3:Use of uninitialized value $opacity in printf at ___.plx line __
Code: Select all
@colors = $image->QueryColor("red");
Also, if I give it an unknown color, I don't get an empty array, at least not exactly. I get an array with one element (according to scalar(@colors)), for example with this:
Code: Select all
@colors = $image->QueryColor("tanfastic");
Another surprise was that the returned results are integers. Calling QueryColor on any of #ff8800, #ffff88880000, or #ffffffff8888888800000000 returns the array (65535, 34952, 0). I'd expected a normalized result. Or perhaps the integers make more sense, depending on the image?
But I notice that it doesn't seem dependent on that, since the following works:
Code: Select all
@colors = Image::Magick->QueryColor("red");
Either way, it would be cool to be able to ask for the format, perhaps like so:
Code: Select all
@colors = $image->QueryColor("red", format => 'real');