Page 1 of 1

Fatal Error using imagecreatefromjpeg( )

Posted: Sun Jan 27, 2008 5:47 pm
by mcccy005
Ok, so I keep getting this error all the time: "Fatal Error: Call to undefined function imagecreatefromjpeg( )in ..."
I've looked around for solutions but nothing seems to work.

I'm not sure if GD is even installed properly. I've placed php_gd2.dll into the correct extensions directory and I've uncommented the line in the php.ini file so that extension=php_gd2.dll is read by php.
When I look at phpinfo( ), the only evidence of GD being anywhere is here at the top of the HTML page:
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
There's no other listing of GD anywhere in the phpinfo page so I have no idea what else to do. I've tried manually loading the extension using dl( ) but it won't allow me to do that either.

I'm using PHP 5.1 on Microsoft IIS 5.1 (on Microsoft Windows XP O/S).
And this is the code where the error is occurring:

Code: Select all

/*Creates a thumbnail version of the image */
if($_FILES[$this->field_name]["type"][$key]=='image/pjpeg'
     || $_FILES[$this->field_name]["type"][$key]=='image/jpeg'
     || $_FILES[$this->field_name]["type"][$key]=='image/JPG')
{
    $img=imagecreatefromjpeg($_FILES[$this->field_name]['tmp_name'][$key]);
}

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Sun Jan 27, 2008 6:07 pm
by Chris Corbyn
Have you restarted the web server (IIS?)?

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Mon Jan 28, 2008 3:01 am
by mcccy005
Yep. I've tried restarting the web server, the computer, everything.
Whatever I do, the error keeps coming up.

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Mon Jan 28, 2008 3:32 am
by Chris Corbyn
Does the php.ini path shown in phpinfo() match the same path to the file you're editting? (i.e. check you're really editting the file PHP takes note of)

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Mon Jan 28, 2008 4:29 am
by mcccy005
Yep - it's the correct file I'm editing.
One thing I just noticed is when I first turn on the computer and open the web browser to localhost, a blank error pops up (ie. it's a box titled "error" and I have to click "OK" but there's no error information). This has only happened since I uncommented the "extension=php_gd2.dll" line in the php.ini file, but when I comment the line again the error doesn't come up.
It's pretty weird because the extensions work fine with php_mysql.dll and php_mysqli.dll in the same folder.

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Mon Jan 28, 2008 4:41 am
by Chris Corbyn
That error sounds like it's due to PHP not being able to load the extension at startup.

Perhaps we need to be looking at your config now.

1. Where is PHP installed on your hard disk?
2. Where is the .dll for GD?
3. What is "extension_dir" set to in your php.ini?
4. What is the path to your php.ini file?

I guess this will provide a quick solution.

:)

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Tue Jan 29, 2008 2:54 am
by mcccy005
Php is installed in S:/Server_Applications/PHP/
php_gd2.dll is located in S:/Server_Applications/PHP/extensions/php_gd2.dll
php.ini is stored in S:/Server_Applications/PHP/php.ini (this is the same as is described when I echo phpinfo( ) )
php.ini describes extension_dir as being S:/Server_Applications/PHP/extensions (I've tried with and without a forward slash at the end of this)

Also, I'm assuming the only way to "install" an extension with php is to add to the php.ini file "extension=php_gd2.dll" and then to add the php_gd.dll file to the directory described in extension_dir in the php.ini file?? I'm not missing something silly am I? As I mentioned earlier - I used to have the same error using mysqli functions and I've installed that file in the same directory as the php_gd.dll file so yeah - I'm a bit stumped.

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Tue Jan 29, 2008 2:56 am
by Chris Corbyn
Try changing the extension_dir to:

"./extensions"

It's a long-shot but I'm not sure how well php handles those absolute windows paths.

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Tue Jan 29, 2008 3:42 am
by Ollie Saunders
It might be both doing a quick check - do other gd functions exist? Try calling gd_info().

Re: Fatal Error using imagecreatefromjpeg( )

Posted: Tue Jan 29, 2008 4:17 am
by mcccy005
Changing the extension to "./extensions" did nothing - ie. everything works as normal (ie. the mysqli extensions) but still nothing with php_gd2.dll (and I tried restarting the web server and everything).

Calling gd_info( ) comes up with "Fatal error: call to undefined function gd_info( ) in ... "

Maybe I should try another php_gd.dll?? (Problem is, I've just been looking for it and can't seem to find it - have downloaded the thing from libgd.org but I can't seem to find the php_gd2.dll file anymore on the web! ANyone know where I can get it from?)

UPDATED: I've downloaded the latest file thing from libgd.org and unzipped it but there's no php_gd.dll file in it?? Maybe someone would be able to send me theirs if I pm my email??