简体   繁体   English

安装GD后imageantialias调用未定义函数错误

[英]imageantialias call to undefined function error with GD installed

I need help with a php script. 我需要有关PHP脚本的帮助。 It is a CMS that has been implemented into a website. 这是已实施到网站中的CMS。 When trying to add a new product IMAGE or trying to edit current images, I am getting the following error: 尝试添加新产品IMAGE或尝试编辑当前图像时,出现以下错误:

Fatal error: Call to undefined function imageantialias() in /home/mounts/home/m/mclh/web/admin/library/functions.php on line 233 致命错误:在第233行的/home/mounts/home/m/mclh/web/admin/library/functions.php中调用未定义的函数imageantialias()

This is my code for that area: 这是我在那方面的代码:

   if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg")
    {
       $destFile  = substr_replace($destFile, 'jpg', -3);
       $dest      = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } elseif ($tmpDest['extension'] == "png") {
       $dest = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } else {
      return false;
    }

Line 233 is the 5th line down. 233行是第五行。

UPDATE : It seems the function imageantialias() is only available if PHP is compiled with GD, so it is not enough to have the extension included via extension file. 更新 :看来功能imageantialias()如果PHP编译GD,所以它是不够的,必须通过扩展文件包括扩展才可用。

From the PHP manual : PHP手册

Note: This function is only available if PHP is compiled with the bundled version of the GD library. 注意:仅当PHP与GD库的捆绑版本一起编译时,此功能才可用。

Please check your phpinfo() and see, if you find the flag --with-gd=shared (or a similar flag, maybe just --with-gd ) in there. 请检查您的phpinfo() ,看看是否在其中找到了--with-gd=shared标志(或类似的标志,也许只是--with-gd )。 If you can't find it, your PHP has to be recompiled with this flag. 如果找不到它,则必须使用此标志重新编译您的PHP。

In more details: PHP extensions can either be loaded by including a .dll (Windows) or .so (Unix) file via php.ini or they can be compiled with PHP. 详细信息:可以通过php.ini通过包含.dll(Windows)或.so(Unix)文件来加载PHP扩展,也可以使用PHP对其进行编译。 Compiling sounds scary and crazy but it is actually really easy. 编译听起来很吓人,但实际上确实很容易。 All you need to do (Unix) is: 您需要做的(Unix)是:

  1. copy the compile string which is shown in your phpinfo() 复制您的phpinfo()中显示的编译字符串
  2. add the required new flag 添加所需的新标志
  3. run
    • ./configure ... all the stuff from your phpinfo plus the new flag ./configure ... phpinfo中的所有内容以及新标记
    • make clean 弄干净
    • make 使
    • make install 进行安装
  4. look at your phpinfo() and smile :) 看看你的phpinfo()和微笑:)

First answer (didn't turn out to be correct): 第一个答案(未证明是正确的):

imageantialias() is a function of the PHP GD extension . imageantialias()PHP GD扩展的功能 Is GD installed and properly configured? GD是否已安装并正确配置?

From your code it seems that GD is installed because imagecreatetruecolor() is also a GD function and seems to work. 从您的代码看来,GD已安装,因为imagecreatetruecolor()也是GD函数,并且似乎可以正常工作。 This leads to the conclusion that you're using a PHP version prior to 4.3.2, which doesn't support imageantialias() . 得出的结论是您使用的是PHP 4.3.2之前的版本,该版本不支持imageantialias()

Please look at your phpinfo() to see if my conclusions are correct. 请查看您的phpinfo()以查看我的结论是否正确。 There you will see what version of PHP your are using and you will also see if GD is installed and working! 在那里,您将看到正在使用的PHP版本,并且还将看到GD是否已安装并正常工作!

这是您问题的解决方法,只需下载rpm,从此处解压缩gd-bundled.so,然后将其替换为原始gd.so。

It seems that the Debian / Ubuntu PHP doesn't bundle the GD library with it, some security reason. 出于安全考虑,Debian / Ubuntu PHP似乎没有将GD库与其捆绑在一起。 You have to recompile PHP, follow this helpful step by step guide on doing so with Debian / Ubuntu: http://www.maxiwebs.co.uk/gd-bundled/compilation.php 您必须重新编译PHP,并遵循有关Debian / Ubuntu的逐步帮助指南: http : //www.maxiwebs.co.uk/gd-bundled/compilation.php

Open up a terminal. 打开一个终端。 Become root by typing su and enter your root password when prompted. 通过键入su成为root用户,并在出现提示时输入您的root密码。

Download some packages we'll need for the install. 下载一些安装所需的软件包。 Type apt-get install build-essential debhelper fakeroot dpkg-dev mysql-server. 输入apt-get install build-essential debhelper fakeroot dpkg-dev mysql-server。 When MySQL install asks for the root password, think of one, then keep it safe. 当MySQL安装程序要求输入root密码时,请考虑一个密码,然后确保密码安全。 Change your current directory to your source one. 将当前目录更改为源目录。 cd /usr/src. cd / usr / src。

Download the PHP 5 source code by typing apt-get source php5. 通过键入apt-get source php5下载PHP 5源代码。 We also need the PHP 5 dependencies. 我们还需要PHP 5依赖项。 To download these, enter apt-get build-dep php5. 要下载这些文件,请输入apt-get build-dep php5。

Go into the downloaded PHP directory. 进入下载的PHP目录。 cd php5-XXXX. cd php5-XXXX。 just press after you've typed php5- to complete the folder name. 键入php5-后,只需按即可完成文件夹名称。

Now we need to edit a config file to change it into the bundled version of GD. 现在,我们需要编辑一个配置文件,以将其更改为GD的捆绑版本。 Type nano debian/rules. 输入nano debian / rules。

Locate the line that says --with-gd=shared,/usr --enable-gd-native-ttf \\ and change it to --with-gd=shared --enable-gd-native-ttf \\ by removing ,/usr. 找到显示--with-gd = shared,/ usr --enable-gd-native-ttf \\的行,并通过删除,/将其更改为--with-gd = shared --enable-gd-native-ttf \\ usr。 (Press ctrl+w to find something, if you search for gd, it is near the second occurrence). (按ctrl + w可以找到某些内容,如果您搜索gd,它就在第二次出现附近)。 To save the file, we need to press ctrl+x then press y and then enter. 要保存文件,我们需要按ctrl + x,然后按y,然后输入。

Now we need to edit the MySQL setup file. 现在我们需要编辑MySQL设置文件。 Type nano debian/setup-mysql.sh. 键入nano debian / setup-mysql.sh。 Note: If this file does not exist, don't worry, you can skip steps 10 and 11. 注意:如果此文件不存在,请放心,您可以跳过步骤10和11。

Find the line $mysqld > $datadir/run.log 2>&1 & and change it to $mysqld --user=root > $datadir/run.log 2>&1 & by adding --user=root to it. 找到$ mysqld> $ datadir / run.log 2>&1&行,然后将--user = root添加到$ mysqld --user = root> $ datadir / run.log 2>&1&行。 To save the file, we need to press ctrl+x then press y and then enter. 要保存文件,我们需要按ctrl + x,然后按y,然后输入。

Now we've done setting up we now need to compile it. 现在我们完成设置,现在需要对其进行编译。 Type dpkg-buildpackage -rfakeroot, or if you're using Ubuntu 11.10, you should type dpkg-buildpackage -d, this will take some time. 输入dpkg-buildpackage -rfakeroot,或者,如果您使用的是Ubuntu 11.10,则应输入dpkg-buildpackage -d,这将需要一些时间。

When it's done, you should have a load of .deb files in the parent directory. 完成后,您应在父目录中加载.deb文件。 Find the one starting with php5-gd. 找到以php5-gd开头的一个。

Install it by double clicking on it, or from the terminal, type dpkg -i php5-gdXXXXXXX just press after you've typed php5-gd to complete the file name. 双击安装它,或在终端上键入dpkg -i php5-gdXXXXXXX,只需在键入php5-gd完成文件名后按即可。

Now we need to stop updates from replacing your shiny new GD library with the regular non-bundled version by holding the package. 现在,我们需要通过拿着软件包来停止将常规的非捆绑版本替换为闪亮的新GD库的更新。 Run the following command: apt-get install wajig. 运行以下命令:apt-get install wajig。 Say yes to the install. 对安装说是。

After the install, enter the following: wajig hold php5-gd. 安装后,输入以下内容:wajig hold php5-gd。

Congratulations! 恭喜你! You now have the bundled version of the GD Library installed, now go and be creative with it! 现在,您已经安装了GD Library的捆绑版本,现在就开始吧!

According to PHP Manual's Changelog for PHP Version 7.2.0 : 根据PHP手册的PHP版本7.2.0的变更日志

imageantialias() is now generally available. imageantialias()现在普遍可用。 Formerly it was only available if PHP was compiled with the bundled version of the GD library. 以前,仅当PHP是使用GD库的捆绑版本编译的时才可用。

So there are some options to fix this. 因此,有一些解决方案。

This function is part of the GD library. 此功能是GD库的一部分。 The library may not be installed in your PHP environment. 该库可能未安装在您的PHP环境中。

Details how to include GD can be found here: http://www.php.net/manual/en/image.installation.php 可以在以下位置找到有关如何包含GD的详细信息: http : //www.php.net/manual/en/image.installation.php

That means you either spelled the imageantialias() function incorrectly or you haven't defined that function in your code or the third party code it belongs to wasn't included in your current document. 这意味着您拼写了imageantialias()函数错误,或者您尚未在代码中定义该函数,或者该函数所属的第三方代码未包含在当前文档中。

UPDATE: GD is installed. 更新:已安装GD。 This is a mystery. 这是一个谜。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 imageantialias在安装了gd的情况下调用未定义的函数错误 - imageantialias call to undefined function error with gd installed 已安装Gd,但“调用未定义的函数imagecreatefromjpeg()” - Gd installed, but “Call to undefined function imagecreatefromjpeg()” Gd和Freetype启用,但仍然出现此错误调用未定义的函数imagettftext() - Gd and Freetype enable but still get this error Call to undefined function imagettftext() 调用未定义的函数 imagecreatefromjpeg() 并启用 GD - Call to undefined function imagecreatefromjpeg() and GD enabled 调用未定义的 function Intervention\Image\Gd\imagejpeg()" - Call to undefined function Intervention\Image\Gd\imagejpeg()" Docker + PHP7 + GD 的问题导致“调用未定义的函数 imagecreatefromjpeg()” - Troubles with Docker + PHP7 + GD resulting in "Call to undefined function imagecreatefromjpeg()" Laravel 调用未定义的函数 Intervention\\Image\\Gd\\imagecreatefrompng() - Laravel Call to undefined function Intervention\Image\Gd\imagecreatefrompng() 调用未定义的函数 imagewebp(Dockerfile、php、gd、webp) - Call to undefined function imagewebp (Dockerfile, php, gd, webp) 调用未定义的函数 Intervention\\\\Image\\\\Gd\\\\imagecreatefromjpeg() - laravel - Call to undefined function Intervention\\Image\\Gd\\imagecreatefromjpeg() - laravel GD装没装? - GD installed or not?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM