I'm trying to create thumbnails for some images. In order to do this I'd like to use the function imagecreatefromjpeg available in the php-gd class (I'm using this function because I found some code on the web that seemed pretty straight forward). However I'm getting the error:
PHP Fatal error: Class 'imagecreatefromjpeg' not found
I've checked that the GD Class is installed and available, and it is:
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.11
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.49
WBMP Support enabled
XPM Support enabled
XBM Support enabled
I've also read that I needed the php-gd packaged installed in my CentOS server, which I it is:
php-gd.x86_64 5.3.3-23.el6_4
I did a quick search for the jpeg library and found:
/usr/lib64/libjpeg.so.62
I also read that I needed to include this library in the php.ini, which I also did:
--with-jpeg-dir=/usr/lib64
My questions:
Current PHP Version: 5.3.3-23.el6_4
Your error message suggests that you're trying to use imagecreatefromjpeg()
as a class and instantiate an object from it. It's not - it's a function.
You've posted no code, but I'd guess that you're doing something like this:
$im = new imagecreatefromjpeg($filename);
when you should be doing this:
$im = imagecreatefromjpeg($filename); // no 'new' keyword.