View Full Version : GD Library not working
frontend
2003-09-02, 06:57 AM
Hi,
I've just put up a site that uses the GD library for scaling images.
I get this:
"Fatal error: Call to undefined function: imagecreatefromjpeg() in "
It worked fine on my previous server, so I assume this has to do with the GD lib, which I think is supposed to come with the server.
What should I do?
regards,
HAC
Is this a Redhat server? Are you using PHP or Perl for your scripts?
GD is normally installed by default. But it is possible that jpeg support is not included.
frontend
2003-09-02, 08:14 AM
Yes, this is a RedHat Power server. I'm also using PHP.
The image i'm processing is a JPEG too.
I've been fiddling around through SSH and found there are no extensions installed. The folder is empty and the lines are commented in PHP.INI.
I'm now trying to figure out how to copy the files to the folder, and make things work.
What's that about JPEG support? Isn't installing GD enough?
Originally posted by frontend
Yes, this is a RedHat Power server. I'm also using PHP.
The image i'm processing is a JPEG too.
I've been fiddling around through SSH and found there are no extensions installed. The folder is empty and the lines are commented in PHP.INI.
I'm now trying to figure out how to copy the files to the folder, and make things work.
What's that about JPEG support? Isn't installing GD enough?
Before you start copying files to the folder, you should create a PHP info page and verify exactly which settings PHP was compiled with. Some modules may be included so they would not show up in the extensions directory.
Just put the following in any 'empty' PHP file:
<? phpinfo(); ?>
GD can be configured with or without jpeg support. You can check for jpeg support with the following command:
/sbin/ldconfig -p | grep libgd
Then you need to take the files from that (.so file) and run this command:
ldd /lib/libgd.so.0
If libjpeg shows up in the ldd command, then it is included.
frontend
2003-09-02, 08:36 AM
No cigar.
The ldconfig command doesn't work, returning "Command not found".
The file's there though. I've tried going to that directory and running it there, but nothing.
frontend
2003-09-02, 08:58 AM
Got it. I was doing it wrong.
Libjpg shows up:
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x40123000)
So, if this is ok, what could me causing the error using the command on PHP?
knightfoo
2003-09-02, 09:59 AM
All of our RedHat servers should have GD 1.8.4 installed and it is integrated with PHP. I created a sample PHP script that implements the imagecreatefromjpeg() function on one of my RedHat 9 test servers and it seems to be working OK. The script is at http://69.44.57.7/imagetest.php and you can view the source at http://69.44.57.7/imagetest.phps.
You can try copying the sample script (which I borrowed from php.net :)) to your server, along with any JPEG image file. Make sure you adjust the path to the JPEG image file for the LoadJpeg() function call. If this script does not work, let us know the following:
1. RedHat version (from /etc/redhat-release)
2. php version (rpm -q php)
3. gd version (rpm -q gd)
4. What control panel and version, if any (CPanel, Ensim, Plesk)
5. Have you done any customizations to the system, especially to PHP?
If this script works on your server and your script does not, it looks like you may have some debugging to do ;)
-knightfoo
frontend
2003-09-02, 10:29 AM
Doesn't work.
Check these out:
www.nnegocios.com/test -> this is the phpinfo() result.
www.nnegocios.com/test.php -> the script. It wasn't doing anything so I removed the @ before imagecreatefromjpeg(). Now it sometimes returns a blank image, sometimes an error (the same I'm getting in my script). I changed the image path to LoadJpeg("test.jpg");
www.nnegocios.com/test.jpg -> you can see the image is there.
This script was working fine on my previous server. Plus it works fine on all our local machines. I really am convinced something's wrong with this server's GD.
My server data: Red Hat 7.3, PHP 4.3.2, GD 1.8.4-4, CPanel. The only thing I've changed was the php.ini on the extensions area, after this problem appeared, but I've just undone those changes.
knightfoo
2003-09-02, 11:12 AM
Hmm .. i am getting a phpinfo page on your first 2 links and a 404 on the test.jpg link. Are you sure the file path is correct? You may need to use the full path to the file on the server.
-knightfoo
frontend
2003-09-02, 11:18 AM
oops, my mistake.
www.nnegocios.com/test
www.nnegocios.com/test/test.php
www.nnegocios.com/test/test.jpg
i left out the directory in the last 2.
knightfoo
2003-09-02, 11:44 AM
OK, it looks like you definitely do not have GD support enabled in PHP. When cPanel installs itself, it compiles its own version of Apache and PHP from source, with whatever configuration options cPanel thinks is appropriate. Apparently the folks at cPanel did not see GD support as a necessary feature.
You should be able to recompile PHP with GD support. Make sure you use all of the options from the "Configure Command" listed in the phpinfo() page, and add the --with-jpeg-dir option to those. You can find the PHP source download and instructions for compiling PHP at http://www.php.net
-knightfoo
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.