Schrift
[thread]5624[/thread]

Grafiken generieren in Perl

Tags: Ähnliche Threads

Leser: 2


<< |< 1 2 >| >> 17 Einträge, 2 Seiten
stb2050
 2003-08-15 18:24
#55369 #55369
User since
2003-08-14
87 Artikel
BenutzerIn
[default_avatar]
Hi Ihr,

wie kann ich eigentlich in Perl Grafiken generieren? Ich möchte einfach eine Grafik 20x200 Pixel, in der in der Mitte ein Text $text steht. Vom Text möchte ich gerne Schriftart $schriftart und Schriftgröße $schriftgroesse sowie Schriftfarbe (HTML-Farbe, #000000) $schriftfarbe anpassen können.

Welche Module brauche ich dafür? Brauche ich überhaupt welche? Wenn ja, wo bekomme ich diese und wie installiere ich diese auf meinem Server? Bin nicht so der Linux-Profi, sorry.

Hat jemand einen Beispiel-Code wie ich das oben von mir genannte schaffen kann?

Viele Grüße & vielen Dank
Steffen
snadra
 2003-08-15 18:45
#55370 #55370
User since
2003-08-11
265 Artikel
BenutzerIn
[Homepage] [default_avatar]
Schau dir mal die CPAN Module Image::Magick, GD und Imager an.
Die können all die Sachen, die Du benötigst...
In deren Doku findest Du auch genug Beispiele um Deine Anforderungen zu  realisieren.\n\n

<!--EDIT|snadra|1060958767-->
http://hamburg.pm.org
jeden 2. mittwoch im monat
--
#!/usr/bin/perl -w
$l=join('',map chr,(116,110,105,114,112))if$^T;
!!$$?@_=qw(Jhfg Aabgure Prey Hnpxre):$l=1;
for(@_){eval reverse($l)."'"._(_(_($_))).' \''}
sub _{$_=~y+a-z+n-za-m+and pop}
kabel
 2003-08-15 18:46
#55371 #55371
User since
2003-08-04
704 Artikel
BenutzerIn
[default_avatar]
z.b. mit gd

codebeispiel siehe synopsis des modules.
zu zeichenketten etc.:
http://search.cpan.org/author....Drawing

du musst vorher gd installiert haben. das geht je nach $DISTRO anders.

HTH\n\n

<!--EDIT|kabel|1060958871-->
-- stefan
Relais
 2003-08-15 18:59
#55372 #55372
User since
2003-08-06
2244 Artikel
ModeratorIn
[Homepage] [default_avatar]
Oder mit THE GIMP Link aus unserer Linkliste http://links.perl-community.de/
Erst denken, dann posten --
26. Deutscher Perl- u. Raku -Workshop 15. bis 17.04.2024 in Frankfurt/M.

Winter is Coming
stb2050
 2003-08-15 21:48
#55373 #55373
User since
2003-08-14
87 Artikel
BenutzerIn
[default_avatar]
Hi Ihr,

danke sehr :-) Habe mich für GD entschieden und nun mal vesucht das Ganze zu installieren.

Habe mir also gd-2.0.15.tar.gz gedownloaded, auf meinem PC entpackt und per WinSCP in das Haupt-Verzeichnis meines Servers hochgeladen (ist es egal wo ich das hochlade?)

Dann habe ich mich per Putty SSH eingeloggt und bin ich das Verzeichnis gegangen.

Wollte nach Anleitung so installieren:

perl makefile.pl
make
make test
make install

Hat aber nicht funktioniert, gleich der erste Befehl nicht. Was mache ich falsch?

Muss ich das ganze in /usr/lib/perl5/site_perl/5.8/ hochladen und die Befehle dann ausführen? Oder ist der Fehler etwas anderes? Es gibt auch noch ein Unterverzeichnis "config" in dem Ordner des Teils. Wenn ich die Befehle da ausprobiere (z.B. make test), dann kommt "make: *** no rule to make target 'test'. Stop".

Viele Grüße und vielen Dank
Steffen\n\n

<!--EDIT|stb2050|1060970426-->
snadra
 2003-08-15 22:11
#55374 #55374
User since
2003-08-11
265 Artikel
BenutzerIn
[Homepage] [default_avatar]
Hallo Steffen,

damit das GD Modul läuft, muß die GD Library auf dem Server installiert sein.
Und es wäre am sinnvollsten das Modul als root zu installieren.
Wenn es sich um einen Webserver handelt, auf dem Du nur Webspace hast, ist das natürlich nicht möglich, aber es kannsein, daß das Modul schon drauf ist. Probier es sonst einfach mal aus...
http://hamburg.pm.org
jeden 2. mittwoch im monat
--
#!/usr/bin/perl -w
$l=join('',map chr,(116,110,105,114,112))if$^T;
!!$$?@_=qw(Jhfg Aabgure Prey Hnpxre):$l=1;
for(@_){eval reverse($l)."'"._(_(_($_))).' \''}
sub _{$_=~y+a-z+n-za-m+and pop}
stb2050
 2003-08-15 22:21
#55375 #55375
User since
2003-08-14
87 Artikel
BenutzerIn
[default_avatar]
Hi,

bin als root eingelogt. Gd libary? wie installiere ich die?

Angeblich ist das GD schon drauf (sagten die Leute beim Support), wenn ich das in Perl aber nutzen will, dann kommt "can't locate ...". Also stimmt da irgendwas nicht. Die Frage ist nur was.

Habe es auch schon in SSH mit "perl -MCPAN -e shell" und dann "install GD;" probiert. Hat auch nicht funktioniert? Brauche ich zusätzlich noch andere Dinge, die ich vorher installieren muss? Freetype oder libdg? Wenn ja, wie mache ich das?

Viele Grüße
Steffen\n\n

<!--EDIT|stb2050|1060972425-->
kabel
 2003-08-15 23:01
#55376 #55376
User since
2003-08-04
704 Artikel
BenutzerIn
[default_avatar]
poste, was du gemacht hast, und wie genau die fehlermeldungen lauten.
das perl-modul GD ist nur ein "aufsatz" auf libgd, um die bibliothek für perl benutzbar zu machen.
-- stefan
stb2050
 2003-08-16 01:39
#55377 #55377
User since
2003-08-14
87 Artikel
BenutzerIn
[default_avatar]
Hi,

bei der Installation von GD bekomme ich folgende Fehlermeldungen:

Quote
-bash: GD.c:2085:: command not found
p15126127:/GD-2.06 # GD.c: In function `XS_GDImage_setBrush':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:: command not found
p15126127:/GD-2.06 # GD.c:2132: parse error before "image"
-bash: GD.c:2132:: command not found
p15126127:/GD-2.06 # GD.c:2137: `image' undeclared (first use in this function)
> GD.c:2137: called object is not a function
> GD.c:2144: `brush' undeclared (first use in this function)
> GD.c:2144: called object is not a function
> GD.c: In function `XS_GDImage_setStyle':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:2169:: command not found
p15126127:/GD-2.06 # GD.c:2196: parse error before "image"
-bash: GD.c:2196:: command not found
p15126127:/GD-2.06 # GD.c:2200: `image' undeclared (first use in this function)
> GD.c:2200: called object is not a function
> GD.c: In function `XS_GDImage_colorClosest':
> GD.c:2262: parse error before "image"
> GD.c:2271: `image' undeclared (first use in this function)
> GD.c:2271: called object is not a function
> GD.c: In function `XS_GDImage_colorExact':
> GD.c:2322: parse error before "image"
> GD.c:2331: `image' undeclared (first use in this function)
-bash: syntax error near unexpected token `('
p15126127:/GD-2.06 # GD.c:2331: called object is not a function
-bash: GD.c:2331:: command not found
p15126127:/GD-2.06 # GD.c: In function `XS_GDImage_colorsTotal':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:: command not found
p15126127:/GD-2.06 # GD.c:2382: parse error before "image"
-bash: GD.c:2382:: command not found
p15126127:/GD-2.06 # GD.c:2388: `image' undeclared (first use in this function)
> GD.c:2388: called object is not a function
> GD.c: In function `XS_GDImage_compare':
> GD.c:2442: parse error before "image1"
> GD.c:2449: `image1' undeclared (first use in this function)
> GD.c:2449: called object is not a function
> GD.c:2456: `image2' undeclared (first use in this function)
-bash: syntax error near unexpected token `('
p15126127:/GD-2.06 # GD.c:2456: called object is not a function
-bash: GD.c:2456:: command not found
p15126127:/GD-2.06 # GD.c: In function `XS_GDImage_copy':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:: command not found
p15126127:/GD-2.06 # GD.c:2502: parse error before "destination"
-bash: GD.c:2502:: command not found
p15126127:/GD-2.06 # GD.c:2513: `destination' undeclared (first use in this function)
> GD.c:2513: called object is not a function
> GD.c:2520: `source' undeclared (first use in this function)
> GD.c:2520: called object is not a function
> GD.c: In function `XS_GDImage_copyResampled':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:2553:: command not found
p15126127:/GD-2.06 # GD.c:2580: parse error before "destination"
-bash: GD.c:2580:: command not found
p15126127:/GD-2.06 # GD.c:2593: `destination' undeclared (first use in this function)
> GD.c:2593: called object is not a function
> GD.c:2600: `source' undeclared (first use in this function)
> GD.c:2600: called object is not a function
> GD.c: In function `XS_GDImage_copyMergeGray':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:2632:: command not found
p15126127:/GD-2.06 # GD.c:2659: parse error before "destination"
-bash: GD.c:2659:: command not found
p15126127:/GD-2.06 # GD.c:2671: `destination' undeclared (first use in this function)
> GD.c:2671: called object is not a function
> GD.c:2678: `source' undeclared (first use in this function)
> GD.c:2678: called object is not a function
> GD.c: In function `XS_GDImage_char':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:2703:: command not found
p15126127:/GD-2.06 # GD.c:2730: parse error before "image"
-bash: GD.c:2730:: command not found
p15126127:/GD-2.06 # GD.c:2739: `image' undeclared (first use in this function)
> GD.c:2739: called object is not a function
> GD.c:2746: `font' undeclared (first use in this function)
> GD.c:2746: called object is not a function
> GD.c: In function `XS_GDImage_string':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:2775:: command not found
p15126127:/GD-2.06 # GD.c:2802: parse error before "image"
-bash: GD.c:2802:: command not found
p15126127:/GD-2.06 # GD.c:2811: `image' undeclared (first use in this function)
> GD.c:2811: called object is not a function
> GD.c:2818: `font' undeclared (first use in this function)
> GD.c:2818: called object is not a function
> GD.c: In function `XS_GDImage_stringFT':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:2847:: command not found
p15126127:/GD-2.06 # GD.xs:1656: `gdImagePtr' undeclared (first use in this function)
> GD.xs:1656: parse error before "img"
> GD.xs:1670: `img' undeclared (first use in this function)
> GD.xs:1670: parse error before "tmp"
> GD.xs:1675: warning: assignment makes pointer from integer without a cast
> GD.c: In function `XS_GDImage_saveAlpha':
> GD.c:2956: parse error before "image"
> GD.c:2961: `image' undeclared (first use in this function)
-bash: syntax error near unexpected token `('
p15126127:/GD-2.06 # GD.c:2961: called object is not a function
-bash: GD.c:2961:: command not found
p15126127:/GD-2.06 # GD.c: In function `XS_GDFont_Large':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:: command not found
p15126127:/GD-2.06 # GD.c:3008: parse error before "RETVAL"
-bash: GD.c:3008:: command not found
p15126127:/GD-2.06 # GD.xs:1730: `RETVAL' undeclared (first use in this function)
> GD.c: In function `XS_GDFont_MediumBold':
> GD.c:3060: parse error before "RETVAL"
> GD.xs:1752: `RETVAL' undeclared (first use in this function)
> GD.c: In function `XS_GDFont_nchars':
> GD.c:3111: parse error before "font"
> GD.c:3117: `font' undeclared (first use in this function)
-bash: syntax error near unexpected token `('
p15126127:/GD-2.06 # GD.c:3117: called object is not a function
-bash: GD.c:3117:: command not found
p15126127:/GD-2.06 # GD.c: In function `XS_GDFont_width':
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: GD.c:: command not found
p15126127:/GD-2.06 # GD.c:3165: parse error before "font"
-bash: GD.c:3165:: command not found
p15126127:/GD-2.06 # GD.c:3171: `font' undeclared (first use in this function)
> GD.c:3171: called object is not a function
> GD.c: In function `XS_GD__Font_height':
> GD.c:3192: parse error before "font"
> GD.c:3198: `font' undeclared (first use in this function)
-bash: syntax error near unexpected token `('
p15126127:/GD-2.06 # GD.c:3198: called object is not a function
-bash: GD.c:3198:: command not found
p15126127:/GD-2.06 # make: *** [GD.o] Error 1
-bash: make:: command not found


Wenn GD auf libgd aufsetzt, muss libgd doch vorhanden sein, wenn ich GD installieren will ...

Ein "locate libgd" ergab folgendes:

Quote
/usr/lib/libgd.so.4
/usr/lib/libgd.so.4.0.0
/usr/lib/libgdbm.a
/usr/lib/libgdbm.la
/usr/lib/libgdbm.so
/usr/lib/libgdbm.so.2
/usr/lib/libgdbm.so.2.0.0
/usr/lib/libgdk-1.2.so.0
/usr/lib/libgdk-1.2.so.0.9.1


Das heißt doch, dass libgd installiert ist, oder nicht?

Viele Grüße
Steffen\n\n

<!--EDIT|stb2050|1060985399-->
Crian
 2003-08-16 05:16
#55378 #55378
User since
2003-08-04
5866 Artikel
ModeratorIn
[Homepage]
user image
Das klingt nach einer defekten Datei... hmm :)

Vielleicht ist es die falsche libgd-Version? Oder stammt alles von der selben Distribution?
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite
<< |< 1 2 >| >> 17 Einträge, 2 Seiten



View all threads created 2003-08-15 18:24.