How do I use gd that comes with PHP?

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
scr0p
Forum Newbie
Posts: 23
Joined: Mon May 05, 2003 6:49 pm
Location: NY

How do I use gd that comes with PHP?

Post by scr0p »

I cant use imagegif() function (I read about what happened with gif format), but that is all my book has examples with, what other functions do I use to show as JPG or PNG?

Code: Select all

<?php
	$id = imagecreate(200, 200 );
	print $id; //this works, but after this, how do I show the 200x200 box
?>
<html>
<head>
<title> .:DynaMo` grafX:. </title>
</head>
<body>
	<img src="grafx.php" alt="PHP generated">
</body>
</html>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

windows php.ini wrote: extension=php_gd.dll
That's presuming you have windows and the gd libraryinstalled with php.

Check out http://www.php.net/gd for further reference.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

ImagePNG($id);
But this out puts an image with image headers so you cannot call it from with a php script. You will need to do something like this, create a script that will only output your image and then call that script as you would a normal image.


Code: Select all

<HTML>
<BODY>
some text here! 
and the image here!
<img src="draw_pic.php">
</BODY>
</HTML>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Re: How do I use gd that comes with PHP?

Post by m3mn0n »

Yea i noticed that too. =P

I suggest using an external file for creation also.
Post Reply