#!/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->rgb($reddish)]}\n";