致命错误:调用未定义函数 imagefilter()
-
05-09-2019 - |
题
是什么导致了这个错误?
Fatal error: Call to undefined function imagefilter() in /var/www/polaroid.php on line 5
1 <?PHP
2 $img_addr = $_GET['image_address'];
3 $img = imagecreatefromjpeg($img_addr);
4
/* everything works as expected without this line */
5 imagefilter($img, IMG_FILTER_GRAYSCALE);
6
7 if ($img)
8 {
/* I moved the header function here so I can see errors in the browser.
If I leave it at the top of the file, the browser expects an image
and doesn't print the error messages. */
9 header('Content-type: image/jpeg');
10 imagejpeg($img);
11 }
12 ?>
13
这是我使用的网址:
http://localhost/polaroid.php?image_address=http://mattnelsoninfo.files.wordpress.com/2008/04/ceiling_cat1.jpg
笔记:gd 列在 phpinfo() 的输出中。
编辑:我使用的是 PHP 版本 5.2.6-2ubuntu4.1
另一个编辑:
phpinfo() 在 gd 部分产生这个
gd
GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.7
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
谢谢!
解决方案
什么版本的PHP您使用的是?它看起来像ImageFilter的是PHP5功能...... HTTP://us3.php达网络/手动/ EN / function.imagefilter.php
编辑: 您的代码工作在我的版本的PHP。作为参考,这是我的phpinfo:
gd
GD Support enabled
**GD Version bundled (2.0.34 compatible)**
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
您可能希望确保该GD版本捆绑。我见过那个安装GD表示支持已启用,但不会捆绑。如果有差别,虽然不能肯定。
其他提示
ImageFilter的似乎仅如果PHP agains绑定的GD库,你的情况是不编译(这是捆绑并启用之间的差异)。由于您使用的Ubuntu,你的仓库不具备GD捆绑找到PHP版本。
http://www.php.net/manual/en/function。 imagefilter.php 有一个通知:
注意强>:如果PHP与编译该函数仅可 捆绑版本GD库的。
正如 2016 年更新一样,PHP 5.3 允许使用外部 GD,但由于某种原因,这在清晰/精确方面不起作用。trusty,使用 PHP 5.5,确实可以使用除 imageantialias、source 之外的所有这些图像函数 https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61 (以及之前的评论)。
不隶属于 StackOverflow