Schrift
[thread]6672[/thread]

Grafiken in Perl: Buchstaben ausgeben....



<< >> 4 Einträge, 1 Seite
Gast Gast
 2005-01-28 17:01
#51408 #51408
Hi!

Wie kann ich mit PERL ein Bild erstellen (PNG, gif o.ä) ?

Das soll kein besonderes Bild werden, eigentlich nur ein bisschen Text auf nem weißen Hintergrund.

Wie mach ich das?!


Danke

Denis Aßmann
betterworld
 2005-01-28 17:08
#51409 #51409
User since
2003-08-21
2613 Artikel
ModeratorIn

user image
CPAN:GD
dassmann
 2005-01-28 20:13
#51410 #51410
User since
2005-01-28
9 Artikel
BenutzerIn
[default_avatar]
Hallo!

Ich hab das jetzt mal probiert, ich werde aber nicht schlau aus GD....

Da gibt es doch garkeine Option damit ich buschstaben ausgeben kann oder?

Jedenfalls hab ichs nochmal mit GD::Text versucht, auch ergebnislos....

Wie soll ich das bitte machen??


Danke im Vorraus

Denis Aßmann
GwenDragon
 2005-01-28 21:23
#51411 #51411
User since
2005-01-17
14607 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-->
<< >> 4 Einträge, 1 Seite



View all threads created 2005-01-28 17:01.