in reply to RGB values and color name

You should be able to use Graphics::ColorNames in conjunction with GD to achieve the desired result.

Added:

#!/usr/bin/perl use strict; use warnings; use Graphics::ColorNames qw( hex2tuple ); use GD; our %COLORS; tie %COLORS, 'Graphics::ColorNames'; my $img = new GD::Image(100, 100); foreach my $color (keys %COLORS) { $img->colorAllocate( hex2tuple( $COLORS{$color} ) ); } my $apricot = $img->colorClosest(255,200,180); print "\$apricot is supposed to be 255 200 180 but is actually @{[$img +->rgb($apricot)]}\n"; my $reddish = $img->colorClosest(223,8,13); print "\$reddish is supposed to be 223 8 13 but is actually @{[$img->r +gb($reddish)]}\n";

Replies are listed 'Best First'.
Re: Re: RGB values and color name
by mdog (Pilgrim) on Aug 25, 2003 at 20:23 UTC
    Many thanks! Exactly what I was looking for....

    Didn't understand that I need to allocate colors before I could use colorClosest. I guess that's why when I tried to use colorClosest and convert it back to RGB it didn't have any other colors to spit back to me than the same color. It didn't know any others.

    PerlMonks rule!