PDA

View Full Version : image GD (php question)


chasebadkids
November 26th, 2006, 11:28 AM
is anyone here good / familiar with image GD ?

if so let me know please I have some questionsss

miller2348
November 26th, 2006, 01:13 PM
what are your questions?

LinkPromo
November 26th, 2006, 01:53 PM
I know a little bit and I'm trying to learn more atm while I'm working on a script.

I don't I'd be of much use, but I'm more than willing to help if I can.

chasebadkids
November 26th, 2006, 03:35 PM
well im trying to dfiure out how to do line breaks
heres 1 script i was using

<?php
$rofl=$_GET['text'];
$pic = imagecreate(200,300);
$backcolor = imagecolorallocate($pic,255,0,0);
$textcolor = imagecolorallocate($pic,255,255,255);
imagefill($pic,0,0,$backcolor);
Imagestring($pic,3,2,0,$rofl,$textcolor);
header('Content-type: image/png');
imagepng($pic);
?>

then in the URL of the script id have it look like
http://www.xgenerators.com/gd/index.php?text=MX\nlol
to do a line break but that wouldnt work
http://www.xgenerators.com/gd/index.php?text=MX%A0lol
so i tried that and it wont work

so i tried another

<?php
header ("Content-type: image/png");
$img_handle = imagecreate (500, 100) or die ("Cannot Create image");
$back_color = imagecolorallocate ($img_handle, 0, 51, 255);
$txt_color = imagecolorallocate ($img_handle, 255, 255, 255);
imagestring ($img_handle, 31, 5, 5, 'My first Program with GD' . "\n" . 'Next line', $txt_color);
imagepng ($img_handle);
?>


but i cant get either working, basically im looking to setup a script that will have lines of text on seperate lines, =X

Greg-J
November 26th, 2006, 04:14 PM
Do you want to let the user define the new line based on a line break contained in a textarea or are deciding where the line break is yourself?

chasebadkids
November 26th, 2006, 04:19 PM
i was going ot have more of a List setup,
so id have it set as to where and how many line breaks would be,

but on a previous page theyd fill out a form and it would have the image made with the seperate lines of text that they put in the previous forms

Greg-J
November 28th, 2006, 12:24 PM
Not knowing your specific application I recommend you go to php.net/gd which I'm sure you have already done.

If you're wanting GD to decide where your linebreaks are, start at http://us2.php.net/manual/en/function.imageftbbox.php otherwise just invoke text for each new line the way you would for a single line.