Help for this page

Select Code to Download


  1. or download this
    use GD;
    
    sub getindex {
    ...
           $image->colorAllocate(@_) :
                $index;
    }
    
  2. or download this
    my $reference_image = new GD::Image(100,100);
    my @colornames;
    {
    ...
        }
        close $rgbdat or die $!;
    }
    
  3. or download this
    my $image = GD::Image->newFromJpeg('many.jpg') or die $!;
    my @size = $image->Bounds();
    
  4. or download this
    my $new_image = GD::Image->new @size;
  5. or download this
    {
        my ($ix, $iy, @rgb);     # preallocate and reuse
        for $ix (0 .. $size[0]-1) {
    ...
            }
        }
    }
    
  6. or download this
    sub getcolor {
        return "puke" unless @_ == 3;
        $colornames[$reference_image->colorClosestHWB(@_)]
    }