use strict; use GD; my $im = new GD::Image(100,100); my @colors; # Preallocate colors, since PNG has a limited number of colors for (0..255) { $colors[$_] = $im->colorAllocate(int(rand(256)),int(rand(256)),int(rand(256))); } for my $x (0..99) { for my $y (0..99) { $im->setPixel($x,$y,$colors[int(rand(255))]); } } binmode STDOUT; print $im->png;