douzhun4124
2014-10-14 08:40
浏览 292
已采纳

调用未定义的函数imagecreatefromjpeg()并启用GD

im working on ubuntu 14.04 LTS with PHP 5.5.9 with GD enabled and i doubled check with but still showing me this msg everytime i try to use imagecreatefromjpeg()

Fatal error: Call to undefined function imagecreatefromjpeg() in /../library/image.php on line 34

i even tried to check on it from command line by using this

php -r "var_dump(function_exists('imageantialias'));"

and it gives me back bool(false)

is there anyway to fix this without re compiling it?

图片转代码服务由CSDN问答提供 功能建议

我在ubuntu上工作14.04 LTS与PHP 5.5.9 启用GD并且我加倍检查 但仍显示 每当我尝试使用imagecreatefromjpeg()

致命错误:在第34行的/../library/image.php中调用未定义的函数imagecreatefromjpeg()

我甚至尝试使用此命令从命令行进行检查

  php -r“var_dump(  function_exists('imageantialias'));“
   
 
 

它让我回来了 bool(false)

无论如何都有 修复此问题而不重新编译它?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douzhan1935 2015-04-16 08:32
    已采纳

    I think you've installed an incomplete version of gd.
    When you compile the gd extension, use the flag --with-jpeg-dir=DIR and --with-freetype-dir=DIR

    ps. dont forget make clean

    picture below is the incomplete version of gd:

    enter image description here

    picture below is the complete version of gd: enter image description here

    点赞 打赏 评论
  • dshdsh2016 2014-10-14 09:04
    Try this
    <?php
    function LoadJpeg($imgname)
    {
        /* Attempt to open */
        $im = @imagecreatefromjpeg($imgname);
    
        /* See if it failed */
        if(!$im)
        {
            /* Create a black image */
            $im  = imagecreatetruecolor(150, 30);
            $bgc = imagecolorallocate($im, 255, 255, 255);
            $tc  = imagecolorallocate($im, 0, 0, 0);
    
            imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
    
            /* Output an error message */
            imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
        }
    
        return $im;
    }
    
    header('Content-Type: image/jpeg');
    
    $img = LoadJpeg('bogus.image');
    
    imagejpeg($img);
    imagedestroy($img);
    ?>
    
    点赞 打赏 评论
  • dqybeh2884 2019-05-06 07:11

    In my case, GD was missing after upgrading to PHP 7.3. So, I just added it by using the following command :

    sudo apt-get install php7.3-gd
    
    点赞 打赏 评论

相关推荐 更多相似问题