dongmi6102 2014-04-11 02:14
浏览 672
已采纳

PHP致命错误:找不到类'imagecreatefromjpeg'

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:

  • How can I validate that the gd library is actually configured and accessible?
  • Is there anything else missing from my configuration?

Current PHP Version: 5.3.3-23.el6_4

  • 写回答

1条回答 默认 最新

  • doumao1887 2014-04-11 02:21
    关注

    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.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?