Staredit Network

Staredit Network -> Computers and Technical -> PHP with GD
Report, edit, etc...Posted by Pie_Sniper on 2006-04-22 at 18:04:01
I've been trying to use GD to create images with PHP. Everything I've read said that to install GD on Windows, all you need to do is uncomment extension=php_gd2.dll (which I have in my /ext directory). So I did that, and it is still say ImageCreate() is an undefined function.

CODE
<?php
 header( "Content-type: image/png" );
 $IMG = ImageCreate( 300, 300 ) or die( "Cannot create image" );
 $BGColor = ImageColorAllocate( $IMG, 0, 0, 0 );
 $FGColor = ImageColorAllocate( $IMG, 255, 255, 255 );
 ImageString( $IMG, 4, 5, 5,  "Bla", $FGColor );
 ImagePng( $IMG );
?>
Report, edit, etc...Posted by Shmeeps on 2006-04-22 at 21:33:58
Do you get an error saying something like "Unable to load dynamic libray <X>"?

Also, are you sure you have the right version, didn't download one for like, Perl, or something like that?
Report, edit, etc...Posted by Pie_Sniper on 2006-04-22 at 22:02:24
Actually, I'm getting a message saying bla bla bla can't be displayed because of errors. But I checked the source and it says:
QUOTE
Fatal error:  Call to undefined function ImageCreate() in C:\Bar\Web\Test.php on line 3

The dll came bundled with PHP5 which I downloaded from http://www.php.net.

:: Edit
Okay, I found that if I change ImageCreate to @ImageCreate, there won't be an error but the title will be Test.php ( Image) rather than Test.php (PNG Image) and it simply displays "http://localhost/Test.php."
Report, edit, etc...Posted by RexyRex on 2006-04-23 at 02:11:49
Then GD isn't installed correctly. I have this problem a TON.

Remember to save the php.ini file and restart Apache.

In the php.ini file, check the extension_dir line and make sure that's correct.
Mine is set to "c:/php/extensions/" because relative pathing had problems (like without "c:/php")...good luck. Extensions are always a pain. smile.gif
Report, edit, etc...Posted by Centreri on 2006-04-23 at 11:01:06
Just wondering, what's GD? I'm quite sure you can use PHP to make images without it. And don't you have to 'release' the image after you use it?
Report, edit, etc...Posted by Shmeeps on 2006-04-23 at 12:55:36
QUOTE(Pie_Sniper @ Apr 22 2006, 09:02 PM)
:: Edit
Okay, I found that if I change ImageCreate to @ImageCreate, there won't be an error but the title will be Test.php ( Image) rather than Test.php (PNG Image) and it simply displays "http://localhost/Test.php."
[right][snapback]470780[/snapback][/right]

Try renaming the file to a *.png and running that.

Also check to make sure your extension directory and directive are pointing to the DLL.
Report, edit, etc...Posted by Doodle77(MM) on 2006-04-23 at 13:21:13
Use a snapshot build and do the same thing. I <3 my snapshot. http://snaps.php.net/
Report, edit, etc...Posted by Pie_Sniper on 2006-04-23 at 13:51:44
» Remember to save the php.ini file and restart Apache.
I've restarted Apache several times and checked the php.ini file over and over.

» In the php.ini file, check the extension_dir line and make sure that's correct.
I've already thought of that, and it is correct.

» Try renaming the file to a *.png and running that.
I'm getting the errors thing with the PHP source in View Source.

» Also check to make sure your extension directory and directive are pointing to the DLL
As I've said, they are.

» Use a snapshot build and do the same thing.
Okay.

:: Edit
Snapshot isn't working either.

:: Edit 2
Here is a better example because I am trying to write text to a .PNG file (this is also my current code):
CODE
<?php
$Filename = "File.png";
$IMG = @imagecreatefrompng( $Filename ) or die( "Cannot open image" );
$BGColor = imagecolorallocate( $IMG, 0, 0, 0 );
$FGColor = imagecolorallocate( $IMG, 255, 255, 255 );
imagestring( $IMG, 4, 5, 5,  "Bla", $FGColor );
imagepng( $IMG, $Filename );
imagedestroy( $IMG );
?>

I threw in some echoes and it is still stopping with @imagecreatefrompng.
Report, edit, etc...Posted by RexyRex on 2006-04-24 at 02:01:16
Is your extension_dir set to an absolute path? Like "c:/php/extensions/"?

That's what got mine to work. smile.gif
Report, edit, etc...Posted by Pie_Sniper on 2006-04-24 at 09:59:50
It is set to C:/Bar/Web/PHP/ext.
Report, edit, etc...Posted by Doodle77(MM) on 2006-04-24 at 16:43:39
Use backslashes.
Report, edit, etc...Posted by Pie_Sniper on 2006-04-24 at 19:47:52
I've messed around with / vs. \ on all these paths.
Report, edit, etc...Posted by RexyRex on 2006-04-24 at 23:49:47
bored.gif

Try installing manually, its not that hard.
Report, edit, etc...Posted by Pie_Sniper on 2006-04-25 at 10:50:41
It was already installed manually, but I might have missed a couple things because it works now... Thanks for all your help though. smile.gif
Next Page (1)