Author Topic: Text to Png  (Read 6964 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Text to Png
« 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:
Code: [Select]
<h2><a class="title" href="../?p=1" rel="bookmark"><?php include ("lol.php?Hallo Welt!"); ?></a></h2>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Text to Png
« Reply #1 on: July 02, 2010, 11:53:20 PM »
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:

Code: [Select]
<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.
« Last Edit: July 03, 2010, 10:18:50 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: Text to Png
« Reply #2 on: July 03, 2010, 09:56:02 AM »
Hallo Vano,

genau das habe ich auch schon gemacht, aber das funktioniert auch nicht. Der Code wird nun so ausgegeben:
Code: [Select]
<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:
Code: [Select]
<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(35075);

//This will make it transparent
imagesavealpha($bgtrue);

$trans_colour imagecolorallocatealpha($bg000127);
imagefill($bg00$trans_colour);

//Text to be written
$helloworld $_GET['text'];

// White text
$white imagecolorallocate($bg255255255);
// Grey Text
$grey imagecolorallocate($bg128128128);
// Black Text
$black imagecolorallocate($bg0,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$fontsize02020$grey$font$helloworld);

//Create image
imagepng($bg);

//destroy image
ImageDestroy($bg);
?>
« Last Edit: July 03, 2010, 10:23:24 AM by Sumale.nin »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Text to Png
« Reply #3 on: July 03, 2010, 10:35:46 PM »
sorry, it should be lol.php?text=Hallo Welt! (I've updated my post above)

regarding Hallo%20Welt%21 - it should not matter.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: Text to Png
« Reply #4 on: July 03, 2010, 11:27:52 PM »
Work!
THX