安装 GD 后 imageantalias 调用未定义函数错误
我需要 php 脚本方面的帮助。它是一个已实施到网站中的 CMS。当尝试添加新产品 IMAGE 或尝试编辑当前图像时,我收到以下错误:
致命错误:调用 /home/mounts/home/m/mclh/web/admin/library/ 中的未定义函数 imageantalias() function.php on line 233
这是我在该区域的代码:
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;
}
第 233 行是向下的第五行。
I need help with a php script. It is a CMS that has been implemented into a website. When trying to add a new product IMAGE or trying to edit current images, I am getting the following error:
Fatal error: Call to undefined function imageantialias() in /home/mounts/home/m/mclh/web/admin/library/functions.php on line 233
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
更新:似乎函数
imageantialias()
仅在使用 GD 编译 PHP 时才可用,因此包含扩展名不足以通过扩展文件。来自 PHP 手册:
请检查您的
phpinfo()
并查看是否找到标志--with-gd=shared
(或类似的标志,可能只是--with- gd
)在那里。如果找不到它,则必须使用此标志重新编译 PHP。更详细地说:
PHP 扩展可以通过 php.ini 包含 .dll (Windows) 或 .so (Unix) 文件来加载,也可以使用 PHP 进行编译。编译听起来很可怕和疯狂,但实际上非常简单。您需要做的(Unix)是:
第一个答案(结果不正确):
imageantialias()
是 PHP GD 扩展 的函数。 GD 是否已安装并正确配置?从您的代码看来,GD 已安装,因为
imagecreatetruecolor()
也是一个 GD 函数并且似乎可以工作。由此得出的结论是,您使用的是 4.3.2 之前的 PHP 版本,该版本不支持imageantialias()
。请查看您的 phpinfo() 看看我的结论是否正确。在那里您将看到您正在使用的 PHP 版本,您还将看到 GD 是否已安装并运行!
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.From the PHP manual:
Please check your
phpinfo()
and see, if you find the flag--with-gd=shared
(or a similar flag, maybe just--with-gd
) in there. If you can't find it, your PHP has to be recompiled with this flag.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. Compiling sounds scary and crazy but it is actually really easy. All you need to do (Unix) is:
First answer (didn't turn out to be correct):
imageantialias()
is a function of the PHP GD extension. Is GD installed and properly configured?From your code it seems that GD is installed because
imagecreatetruecolor()
is also a GD function and seems to work. This leads to the conclusion that you're using a PHP version prior to 4.3.2, which doesn't supportimageantialias()
.Please look at your phpinfo() to see if my conclusions are correct. There you will see what version of PHP your are using and you will also see if GD is installed and working!
根据 PHP 手册的 PHP 版本 7.2.0 的变更日志< /a>:
所以有一些选项可以解决这个问题。
--with-gd
标志的./configure
脚本编译 php。According to PHP Manual's Changelog for PHP Version 7.2.0:
So there are some options to fix this.
./configure
script with--with-gd
flag.出于安全原因,Debian / Ubuntu PHP 似乎没有捆绑 GD 库。您必须重新编译 PHP,请按照以下有用的分步指南在 Debian / Ubuntu 上执行此操作: http://www.maxiwebs.co.uk/gd-bundled/compilation.php
打开终端。
输入 su 成为 root,并在出现提示时输入 root 密码。
下载安装所需的一些软件包。键入 apt-get install build-essential debhelper fakeroot dpkg-dev mysql-server。当 MySQL 安装要求输入 root 密码时,请想出一个密码,然后妥善保管。
将当前目录更改为源目录。 cd /usr/src。
通过输入 apt-get source php5 下载 PHP 5 源代码。
我们还需要 PHP 5 依赖项。要下载这些,请输入 apt-get build-dep php5。
进入下载的 PHP 目录。 cd php5-XXXX。只需在输入 php5- 后按 即可完成文件夹名称。
现在我们需要编辑一个配置文件,将其更改为 GD 的捆绑版本。输入 nano debian/rules。
找到 --with-gd=shared,/usr --enable-gd-native-ttf \ 行,并将其更改为 --with-gd=shared --enable-gd-native-ttf \ 通过删除 ,/ usr。 (按ctrl+w查找某些内容,如果搜索gd,它就在第二次出现附近)。要保存文件,我们需要按ctrl+x然后按y然后回车。
现在我们需要编辑 MySQL 安装文件。输入 nano debian/setup-mysql.sh。注意:如果该文件不存在,不用担心,可以跳过步骤 10 和 11。
找到 $mysqld > 行$datadir/run.log 2>&1 &并将其更改为 $mysqld --user=root > $datadir/run.log 2>&1 &通过添加 --user=root 到它。要保存文件,我们需要按ctrl+x然后按y然后回车。
现在我们已经完成了设置,现在需要编译它。输入 dpkg-buildpackage -rfakeroot,或者如果您使用的是 Ubuntu 11.10,则应该输入 dpkg-buildpackage -d,这将需要一些时间。
完成后,您应该在父目录中加载 .deb 文件。找到以 php5-gd 开头的。
通过双击安装它,或者从终端输入 dpkg -i php5-gdXXXXXXX,只需在输入 php5-gd 完成文件名后按按即可。
现在我们需要通过保存包来阻止更新将闪亮的新 GD 库替换为常规的非捆绑版本。运行以下命令:apt-get install wajig。
同意安装。
安装后,输入以下内容:wajighold php5-gd。
恭喜!您现在已经安装了 GD 库的捆绑版本,现在就开始发挥创意吧!
It seems that the Debian / Ubuntu PHP doesn't bundle the GD library with it, some security reason. 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
Open up a terminal.
Become root by typing su and enter your root password when prompted.
Download some packages we'll need for the install. Type 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.
Change your current directory to your source one. cd /usr/src.
Download the PHP 5 source code by typing apt-get source php5.
We also need the PHP 5 dependencies. To download these, enter apt-get build-dep php5.
Go into the downloaded PHP directory. cd php5-XXXX. just press after you've typed php5- to complete the folder name.
Now we need to edit a config file to change it into the bundled version of GD. Type 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. (Press ctrl+w to find something, if you search for gd, it is near the second occurrence). To save the file, we need to press ctrl+x then press y and then enter.
Now we need to edit the MySQL setup file. Type nano debian/setup-mysql.sh. Note: If this file does not exist, don't worry, you can skip steps 10 and 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. To save the file, we need to press ctrl+x then press y and then enter.
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.
When it's done, you should have a load of .deb files in the parent directory. Find the one starting with 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.
Now we need to stop updates from replacing your shiny new GD library with the regular non-bundled version by holding the package. Run the following command: apt-get install wajig.
Say yes to the install.
After the install, enter the following: wajig hold php5-gd.
Congratulations! You now have the bundled version of the GD Library installed, now go and be creative with it!
这里是解决您的问题的方法
只需下载 rpm,从此处提取 gd-bundled.so 并用它替换原来的 gd.so 即可。
Here is workaround for your issue
Just download the rpm, extract gd-bundled.so from here and replace original gd.so with it.
该函数是 GD 库的一部分。您的 PHP 环境中可能未安装该库。
有关如何包含 GD 的详细信息,请参见:http://www.php.net /manual/en/image.installation.php
This function is part of the GD library. The library may not be installed in your PHP environment.
Details how to include GD can be found here: http://www.php.net/manual/en/image.installation.php
这意味着您的
imageantialias()
函数拼写错误,或者您尚未在代码中定义该函数,或者它所属的第三方代码未包含在您当前的文档中。更新:
GD已安装。这是一个谜。
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.UPDATE:
GD is installed. This is a mystery.