GD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

GD

Post 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.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post 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.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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.
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Um..yeah, I understand like none of that..this is why I am looking for a tutorial.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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).
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Yeah, I know. Same here..I read through the damn thing and got about 2 sentences in! It's nuts!!
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

this link may be of some help :


viewtopic.php?t=14566&highlight=gd+library
Post Reply