Farid Hajji: Perl - Einführung, Anwendungen, Referenz
2., aktualisierte und erweiterte Auflage
Addison-Wesley Longman, ISBN 3-8273-1535-2
cgi-welcome-gd.pl
#!/usr/local/bin/perl -w
# cgi-welcome-gd.pl -- Eine dynamische GIF-Datei mit GD.pm
use CGI qw(:standard);
use GD;
use strict;
use constant HEIGHT => 25;
use constant WIDTH => 250;
use constant COLOR => (255, 0, 0);
# Wir erzeugen irgendeinen beliebigen Text.
use constant MAXHITS => 1_000_000;
my $info = "Your magic cookie: " . int(rand(MAXHITS));
# Nun zeichnen wir das Objekt:
drawme($info);
sub drawme {
my $info = shift;
# Wir erzeugen ein 100x30 Pixel breites Bild:
my $im = new GD::Image(WIDTH, HEIGHT);
# Die folgenden Farben benoetigen wir:
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate( 0, 0, 0);
my $color = $im->colorAllocate( COLOR );
# Einige Einstellungen zum Bild:
$im->transparent($white);
$im->interlaced('true');
# Nun zeichnen wir:
$im->filledRectangle(0, 0, WIDTH-1, HEIGHT-1, $black);
$im->string(gdGiantFont, 5, 5, $info, $color);
# Wir erzeugen nun ein GIF-Bild daraus:
my $gif = $im->gif();
# Das geben wir nun aus:
print header({-type => 'image/gif', -expires => '+1s',
-length => length($gif)}),
$gif;
}
[Prev] [Up] [Relevant Chapter] [Next]
[Alte Quelle]
| Last modified: $Date: 2006/05/18 12:55:53 $ FH. Search :: Sitemap :: Disclaimer :: Copyright :: Privacy |
|