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

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!