質問

このエラーの原因は何?

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 

ありがとうございます。

役に立ちましたか?

解決

あなたが使用しているPHPのバージョンは何? ImageFilterがPHP5機能であるように見えます... のhttp://us3.php .NET /マニュアル/ 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があなたのケースで、それは(それがバンドルされ、有効との違いだ)ではありません同梱GDライブラリagainsコンパイルされている場合のみ利用可能であるように思われます。 Ubuntuを使っているので、あなたがリポジトリに見つけるPHPのバージョンが同梱GDていません。

http://www.php.net/manual/en/function。 imagefilter.phpは予告あります:

  

:PHPがコンパイルされている場合、この機能はのみ使用可能です   バンドル版のGDライブラリます。

ただ、2016年のアップデートとして、PHP 5.3は、外部GDを使用することが許されますが、これは明快/精密で、何らかの理由で動作しませんでした。 PHP 5.5で、imageantialias除いて働くすべてのこれらの画像機能を持っていない、信頼できる、ソース<のhref =「https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61」のrel = "nofollowをnoreferrer"> https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61 の(および以前のコメント)。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top