PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Frage zu imagettftext



tomes
11-04-2002, 12:30
Wie kann man es hinbekommen, dass das erzeugte Bild ein Link ist?
Irgendwie komme ich mit den Header() Befehl nicht zurecht.
Bei Content-type: image/jpeg kann ich kein anderen Text in den Code reinschreiben, bei Content.type: text/html wird das Bild nicht angezeigt.
Irgendwo fehlt mir da was. Aber was ?

T;o)Mes

netzmeister
30-04-2002, 19:58
Hallo,

schaue mal bei ZEND: http://www.zend.com/codex.php?CID=13

Oder hier habe ich noch ein Codeschinpsel:




<?php
/*
Quote generator 0.01
This scripts generates a gif image produced on the fly with the gd-library.
I used it to get quotes from a file and display them in an image. This was made to
make it possible for "out-site-users" to show the quotes i have collected.
It expects to get the following variables sent to it:
$filename : the name of the file containing quotes or other things separated with #.
$path_to_font_file : the path to the true type font file
$steal : (optional) This makes it possible to output a specific line in the file. Good for debugging.
The script is limited to output 3 lines(and 1 static line) in the image. It can easily be changed by doing it
bigger and add more lines at appropriate places.
The script could be included on a page by calling it with a regular <img src="/path to script">.
Copyleft(L) 1999 Eric Persson, eric@persson.tm, http://www.persson.tm/scripts/
*/
//this code below sends headers to the b
// rowser to make it think its always updat
// ed and should not be taken from cache.
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate");// HTTP/1.1
header("Pragma: no-cache");// HTTP/1.0
//code below puts each line in to the array $file_content
$fd = fopen("$filename", "r"); //opens the specified file
while ($file_content[] = fgets($fd, 4096)) { //this limits the file(test.rem) to 4096 bytes. 4096 bytes is allocated in memory. Can be increased to load bigger files.
}
fclose($fd);
if(isset($steal)){ //makes it possible to skip the randomizer and pick up a specific row.
$test=$steal;
}else{
$arraysize=sizeof($file_content); //gets the size of the array
sRand(date("s")*(date("H")+1)); //includes the seconds and hours in the randomizer to "garantuee" it wont display same things in a row
$random=(1 + Rand(0,$arraysize-3));
$random=floor($random); //lowers the value of $random since its hard to take a half line. :-)
};
$selected_line=$file_content[$random];
$splitted_line = split( "#", $selected_line, 5 ); //splits the line at the occurrencies of #
Header("Content-type: image/gif"); //sends a imagetype header to the browser.
$im = imagecreate(250,45); //decides the size of the image created
$black = ImageColorAllocate($im, 255,255,255);
$white = ImageColorAllocate($im, 0,0,0);
$grey = ImageColorAllocate($im, 153,153,153);
ImageTTFText($im, 10, 0, 2, 10, $white, "$path_to_font_file", "$splitted_line[0]");
ImageTTFText($im, 10, 0, 2, 20, $white, "$path_to_font_file", "$splitted_line[1]");
ImageTTFText($im, 10, 0, 2, 30, $white, "$path_to_font_file", "$splitted_line[2]");
ImageTTFText($im, 10, 0, 2, 40, $grey, "$path_to_font_file", "www.persson.tm/scripts/");
ImageGif($im);
ImageDestroy($im);
?>



Viel Erfolg

Eicke