imagecreatefromjpeg and similar functions are not working in PHP

前端 未结 11 1031
攒了一身酷
攒了一身酷 2020-12-08 09:06

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

相关标签:
11条回答
  • 2020-12-08 09:21

    In Ubuntu/Mint (Debian based)

    $ sudo apt-get install php5-gd
    
    0 讨论(0)
  • 2020-12-08 09:24

    after
    systemctl restart php-fpm
    the Gd library works.

    0 讨论(0)
  • 2020-12-08 09:28

    For php 7 on Ubuntu:

    sudo apt-get install php7.0-gd

    0 讨论(0)
  • 2020-12-08 09:30

    As mentioned before, you might need GD library installed.

    On a shell, check your php version first:
    php -v

    Then install accordingly. In my system (Linux-Ubuntu) it's php version 7.0:
    sudo apt-get install php7.0-gd

    Restart your webserver:
    systemctl restart apache2

    You should now have GD library installed and enabled.

    0 讨论(0)
  • 2020-12-08 09:33

    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.

    0 讨论(0)
  • 2020-12-08 09:35

    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/

    0 讨论(0)
提交回复
热议问题