Page 1 of 1
GD
Posted: Mon Jan 19, 2004 12:26 pm
by Straterra
I was wondering, can you use GD to dynamically put text on pictures? If so, can someone point me towards a tutorial? I have googled for one, but came up empty handed.
Posted: Mon Jan 19, 2004 12:37 pm
by dull1554
Posted: Mon Jan 19, 2004 12:39 pm
by Straterra
Yeah, I am looking at that (
http://us3.php.net/image) but, it doesn't give any examples that I am finding useful... Like, for example, how to open an image for editing.
Posted: Mon Jan 19, 2004 12:43 pm
by dull1554
Code: Select all
<?php
header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("images/button1.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);
?>
how bout that, it overlays the text over the png and creates a new one.
Posted: Mon Jan 19, 2004 12:48 pm
by Straterra
Um..yeah, I understand like none of that..this is why I am looking for a tutorial.
Posted: Mon Jan 19, 2004 12:54 pm
by dull1554
i'm sorry, i've been looking for a GD tutorial but i have not been able to find one that covers what i belive needs to be covered, so im currently reading the GD manual(even though it is not a manual i'm still reading it and becoming so confused it is not even funny).
Posted: Mon Jan 19, 2004 1:32 pm
by Straterra
Yeah, I know. Same here..I read through the damn thing and got about 2 sentences in! It's nuts!!
Posted: Mon Jan 19, 2004 1:52 pm
by dull1554
they need to start printing those damn manuals in english, or a humanoid language!!!!!!!!!!!!!!!!
and by the way my the force be with you(hope u figure it out)
Posted: Mon Jan 19, 2004 2:03 pm
by Roja
Dull, forgive me for using your code..
With commentary to clarify:
dull1554 wrote:Code: Select all
<?php
header("Content-type: image/png"); //Tell the browser that an image is coming
$string = $_GET['text']; // Set variable to text to put on top of image
$im = imagecreatefrompng("images/button1.png"); // Make an image ($im) FROM (based on) button1.png
$orange = imagecolorallocate($im, 220, 210, 60); // $orange is the rgb values for orange.
$px = (imagesx($im) - 7.5 * strlen($string)) / 2; // What size should the text be in pixels, based on the length of the string
imagestring($im, 3, $px, 9, $string, $orange); // Put the text on the picture at size $px, in color $orange.
imagepng($im); // Output the now-modified picture.
imagedestroy($im); // Delete the picture from memory.
?>
Hope that helps.
Posted: Mon Jan 19, 2004 3:07 pm
by dull1554
@ Roja
it's no problem, i have a question for you seeing that you know what your doing, i use some GD commands but i can only test these so called "GD" scripts on my web server, and not on my local server, i was not the one who set up GD on my server so i don't know how to nor have found install directions that i can understand, is there a place that tells me what i need to download and how to install it so i can use GD on my local server
Posted: Mon Jan 19, 2004 9:26 pm
by infolock