문제

이 오류의 원인은 무엇입니까?

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/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 지원이 활성화되었지만 번들로는 설치되지 않은 설치를 보았습니다. 그래도 차이가 있는지 확실하지 않습니다.

다른 팁

ImageFilter는 PHP가 번들 GD 라이브러리를 다시 컴파일하는 경우에만 사용할 수있는 것 같습니다. Ubuntu를 사용하기 때문에 저장소에서 찾은 PHP 버전에는 GD 번들이 없습니다.

http://www.php.net/manual/en/function.imagefilter.php 통지가 있습니다.

메모:이 기능은 PHP가 GD 라이브러리의 번들 버전으로 컴파일 된 경우에만 사용할 수 있습니다.

2016 년 업데이트와 마찬가지로 PHP 5.3은 외부 GD를 사용할 수 있었지만 이는 Lucid/Precise에서 어떤 이유로 작동하지 않았습니다. PHP 5.5를 사용하여 신뢰할 때,이 이미지 기능은 ImageAntialias, Source를 제외하고 작동합니다. https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61 (및 이전 의견).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top