use strict;
use warnings;
use GD;

my($bild, $breite, $hoehe);

open (IMG,"<", "hv.gif") ||  die "Kein Bild\n";
$bild = GD::Image->newFromGif(\*IMG);
close(IMG);

($breite, $hoehe) = $bild->getBounds();
print "Breite: $breite, Hoehe: $hoehe\n";
print "das Bild hat ",$bild->colorsTotal()," Farben\n";

my $rot = $bild->colorExact(255,0,0);
die "Farbe nicht gefunden\n" if $rot == -1;
my $yellow = $bild->colorAllocate(255,255,0);

for my $i (0..$breite-1)
  {
  for my $j (0..$hoehe-1)
    {
    if ($bild->getPixel($i,$j) == $rot)
      { $bild->setPixel($i,$j,$yellow); }
    }
  }

open(OUT, ">", "hvg.gif") || die "Oops: $!\n";
binmode(OUT);
print OUT $bild->gif;
close(OUT);