imagecreatefromjpeg and similar functions are not working in PHP

浪子不回头ぞ 提交于 2019-12-17 15:46:18

问题


I’ve searched for this and the solutions provided in past questions are completely incomprehensible to me. Whenever I run functions like imagecreatefromjpeg, I get this:

Fatal error: Call to undefined function imagecreatefromjpeg() ...

I’m working on a new install of PHP; my last installation never had this problem. I don’t get what’s going on.


回答1:


Install GD Library

Which OS you are using?

http://php.net/manual/en/image.installation.php

Windows http://www.dmxzone.com/go/5001/how-do-i-install-gd-in-windows/

Linux http://www.cyberciti.biz/faq/ubuntu-linux-install-or-add-php-gd-support-to-apache/




回答2:


In Ubuntu/Mint (Debian based)

$ sudo apt-get install php5-gd



回答3:


You must enable the library GD2.

Find your (proper) php.ini file

Find the line: ;extension=php_gd2.dll and remove the semicolon in the front.

The line should look like this:

extension=php_gd2.dll

Then restart apache and you should be good to go.




回答4:


sudo apt-get install phpx.x-gd 
sudo service apache2 restart

x.x is the versión php.




回答5:


You can still get Fatal error: Call to undefined function imagecreatefromjpeg() even if GD is installed.

The solution is to install/enable jped lib:

On Ubuntu:

    apt-get install libjpeg-dev
    apt-get install libfreetype6-dev

On CentOS:

    yum install libjpeg-devel
    yum install freetype-devel

If compiling from source add --with-jpeg-dir --with-freetype-dir or --with-jpeg-dir=/usr --with-freetype-dir=/usr.

For more details check https://www.tectut.com/2015/10/solved-call-to-undefined-function-imagecreatefromjpeg/




回答6:


After installing php5-gd apache restart is needed.




回答7:


For php 7 on Ubuntu:

sudo apt-get install php7.0-gd




回答8:


In CentOS, RedHat, etc. use below command. don't forget to restart the Apache. Because the PHP module has to be loaded.

yum -y install php-gd
service httpd restart


来源:https://stackoverflow.com/questions/13338339/imagecreatefromjpeg-and-similar-functions-are-not-working-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!