Fatal error: Llamada a imagefilter función no definida ()
-
05-09-2019 - |
Pregunta
¿Qué está causando este 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
Esta es la URL que utilizo:
http://localhost/polaroid.php?image_address=http://mattnelsoninfo.files.wordpress.com/2008/04/ceiling_cat1.jpg
NOTA: gd aparece en la salida de phpinfo ().
EDIT: Estoy usando la versión PHP 5.2.6-2ubuntu4.1
Otro EDIT:
phpinfo () produce esto en la sección 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
Gracias!
Solución
¿Qué versión de PHP está usando? Parece que es una función imagefilter PHP5 ... http: //us3.php .NET / manual / es / function.imagefilter.php
EDIT: Su código funciona en mi versión de PHP. Como referencia, aquí está mi 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
Es posible que desee asegurarse de que la versión GD se lía. He visto las instalaciones que dicen GD está habilitado el soporte pero no incluido. No estoy seguro si eso hace la diferencia sin embargo.
Otros consejos
imagefilter parece estar disponible únicamente si PHP se compila agains de la biblioteca GD liado que en su caso no es (que es la diferencia entre el paquete y habilitado). Dado que está utilizando Ubuntu la versión de PHP que se encuentran en el repositorio no se han incluido GD.
http://www.php.net/manual/en/function. imagefilter.php hay un aviso:
Nota: : Esta función sólo está disponible si PHP se compila con el versión integrada de la librería GD.
Al igual que una actualización de 2016, PHP 5.3 GD permitido externo para ser utilizado, pero esto no funciona por alguna razón en lúcida / precisa. de confianza, con PHP 5.5, no tiene todas estas funciones de imagen laborables excepto imageantialias, fuente https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61 (y los comentarios anteriores).