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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?