4images Forum & Community
General / Allgemeines => Programming => Topic started by: Sunny C. on July 02, 2010, 07:38:15 PM
-
Hello i write a script to show text to png.
http://gn.germannaruto.de/wp-gallerie/lol.php?text=woot!
Works fine, but i cant use in home.html
Like:
<h2><a class="title" href="../?p=1" rel="bookmark"><?php include ("lol.php?Hallo Welt!"); ?></a></h2>
-
Don't forget, that template files are being executed via functions, so if your included script requires some global variables, you'll need use global keyword before it will be able use them.
Then, you can't use query type strings in the path for a local include.
And finally, your script generates image itself, not HTML code, you need use it like this instead:
<h2><a class="title" href="../?p=1" rel="bookmark"><img src="lol.php?text=Hallo Welt!"></a></h2>
P.S.
Please post such questions in programming section, as it's clearly not related to 4images package itself.
-
Hallo Vano,
genau das habe ich auch schon gemacht, aber das funktioniert auch nicht. Der Code wird nun so ausgegeben:
<a class="title" href="../?p=1" rel="bookmark"><img src="lol.php?Hallo%20Welt%21"></a>
//
Hello Vano,
I have already made exactly this, but this also does not function. Now the code is given thus:
<a class = "headlines" href = "./? p=1" rel = "bookmark"> <img src = "lol.php? Hallo%20Welt%21"> </a>
The Code
<?php
header("Content-type: image/png"); //Picture Format
header("Expires: Mon, 01 Jul 2003 00:00:00 GMT"); // Past date
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Consitnuously modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // NO CACHE
/*image generation code*/
//create Image of size 350px x 75px
$bg = imagecreatetruecolor(350, 75);
//This will make it transparent
imagesavealpha($bg, true);
$trans_colour = imagecolorallocatealpha($bg, 0, 0, 0, 127);
imagefill($bg, 0, 0, $trans_colour);
//Text to be written
$helloworld = $_GET['text'];
// White text
$white = imagecolorallocate($bg, 255, 255, 255);
// Grey Text
$grey = imagecolorallocate($bg, 128, 128, 128);
// Black Text
$black = imagecolorallocate($bg, 0,0,0);
$font = 'Alibi___.ttf'; //path to font you want to use
$fontsize = 20; //size of font
//Writes text to the image using fonts using FreeType 2
imagettftext($bg, $fontsize, 0, 20, 20, $grey, $font, $helloworld);
//Create image
imagepng($bg);
//destroy image
ImageDestroy($bg);
?>
-
sorry, it should be lol.php?text=Hallo Welt! (I've updated my post above)
regarding Hallo%20Welt%21 - it should not matter.
-
Work!
THX