Thread Grafiken in Perl: Buchstaben ausgeben.... (3 answers)
Opened by Gast at 2005-01-28 17:01

GwenDragon
 2005-01-28 21:23
#51411 #51411
User since
2005-01-17
14794 Artikel
Admin1
[Homepage]
user image
Das Modul GD hat die Unterstützung von internen Fonts und TrueType.

Beispiel mit TrueType:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl

use GD;

my $im = new GD::Image(100,50);

# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);       
$red = $im->colorAllocate(255,0,0);      
$blue = $im->colorAllocate(0,0,255);

# And fill it with red
$im->fill(1,1,$red);

my $fontsize = 20; # 20px Font
my $x = 0; 
my $y = $fontsize;
    
$im->stringFT($black,'C:/WIN/FONTS/ARIAL.TTF',$fontsize, 0, $x, $y, "Hallo");
              
print "Content-Type: image/png

";

binmode STDOUT;

# Convert the image to PNG and print it on standard output
print $im->png;


Ein bisschen davon in eine Funktion verpackt und es lassen sich Buchstabenfolgen (auch als einzelne Bilder) ausgeben.\n\n

<!--EDIT|GwenDragon|1106942379-->

View full thread Grafiken in Perl: Buchstaben ausgeben....