Page 1 of 1

Another GD Question.

Posted: Mon Nov 21, 2005 9:24 am
by dcahrakos
Well, right now, I can get text into a generated image, and everything, but say I wanted to do this:


http://dcah.z27.net/board/txt.php?txt=Need to have a line break<br>here

is there a way I can make it so, wherever I have <br> or even \n or anything really, be replaced with an actual line break? ive tried eregi_replace, explode, etc...but I can figure it out.

Posted: Mon Nov 21, 2005 9:34 am
by dyonak
I haven't tested this but I assume all you would need is a

Code: Select all

urlencode($_GET['string']);
This will lend proper syntax to your url ie http://dcah.z27.net/board/txt.php?txt=N ... line+break

Edit:
My bad you aren't looking for spaces, though you may need that as well. For line breaks I'm not sure but I would try to code that into your GD script, pass it some type of indicator like if you want to use <br /> just have your GD script look through the string for <br />'s as an explode point. With the array that it generates you can run the script multiple times for each line.

Posted: Mon Nov 21, 2005 9:40 am
by dcahrakos
nope...that just messes everything up, and makes certain characters turn into stuff like %20%13 etc etc...and it changes <br> into %3Cbr%3E so thats not what im looking for.

im not sure if you know what I was saying though, basically, the script outputs an image with the text based on the string variable, and doing that, line breaks dont work, so I want it so I can do the following

something<br>
then after the br it goes on another line.

Posted: Mon Nov 21, 2005 9:53 am
by dyonak
Sorry for the misread there. For line breaks I'm not sure but I would try to code that into your GD script, pass it some type of indicator like if you want to use <br /> just have your GD script look through the string for <br />'s as an explode point. With the array that it generates you can run the script multiple times for each line.

Posted: Mon Nov 21, 2005 9:54 am
by Jenk
In a word, no.

In a long, probably hair pulling function, yes.

Line breaks are not "possible" in the method in what you ask, each line must be added with imagettftext() or similar function.

So something like:

Code: Select all

<?php

$lines = explode("\n", $_GET['text']);

foreach ($lines as $line => $val) {
    imagettftext($image, $size, $angle, $x, (($y + $size) * ($line + 1)), $colour, $fontfile, $val);
}

?>
untestedâ„¢

Posted: Mon Nov 21, 2005 10:03 am
by dcahrakos
hmmm...thought it would have been a little easier then that, but ill try that out in a bit, thanks.