致命错误:调用未定义的函数 imagefilter()

发布于 2024-07-13 10:42:01 字数 1290 浏览 7 评论 0 原文

是什么导致了这个错误?

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

这是我使用的 URL:

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 

谢谢!

What is causing this error?

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

This is the URL I use:

http://localhost/polaroid.php?image_address=http://mattnelsoninfo.files.wordpress.com/2008/04/ceiling_cat1.jpg

NOTE: gd is listed in the output from phpinfo().

EDIT: I'm using PHP Version 5.2.6-2ubuntu4.1

Another EDIT:

phpinfo() yields this in the gd section

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 

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

电影里的梦 2024-07-20 10:42:01

imagefilter 似乎只有在 PHP 再次编译捆绑的 GD 库时才可用,而在您的情况下则不然(这就是捆绑和启用之间的区别)。 由于您使用的是 Ubuntu,因此您在存储库中找到的 php 版本没有捆绑 GD。

imagefilter seems to be available only if PHP is compiled agains the bundled GD library which in your case it's not (that's the difference between the bundled and enabled). Since you're using Ubuntu the version of php that you find in the repository does not have GD bundled.

剪不断理还乱 2024-07-20 10:42:01

您使用什么版本的 PHP? 看起来 imagefilter 是一个 PHP5 函数... https://www.php .net/manual/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 支持已启用但未捆绑。 但不确定这是否有什么不同。

What version of PHP are you using? It looks like imagefilter is a PHP5 function ... https://www.php.net/manual/en/function.imagefilter.php

EDIT:
Your code works on my version of PHP. For reference, here's my 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

You might want to make sure that the GD Version is bundled. I've seen installations that say GD Support is enabled but not bundled. Not sure if that makes a difference though.

‖放下 2024-07-20 10:42:01

http://www.php.net/manual/en/function.imagefilter.php 有一个通知:

注意:此函数仅在 PHP 编译时可用
GD 库的捆绑版本。

http://www.php.net/manual/en/function.imagefilter.php there is a notice:

Note: This function is only available if PHP is compiled with the
bundled version of the GD library.

独留℉清风醉 2024-07-20 10:42:01

正如 2016 年更新一样,PHP 5.3 允许使用外部 GD,但由于某种原因,这在清晰/精确方面不起作用。 trusty,使用 PHP 5.5,确实可以使用除 imageantialias 之外的所有这些图像功能,source https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61(以及之前的评论)。

Just as a 2016 update, PHP 5.3 allowed external GD to be used, but this didn't work for some reason in lucid/precise. trusty, with PHP 5.5, does have all these image functions working except imageantialias, source https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61 (and previous comments).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文