Errore fatale:Chiamata alla funzione non definita imagefilter()
-
05-09-2019 - |
Domanda
Cosa causa questo errore?
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
Questo è l'URL che utilizzo:
http://localhost/polaroid.php?image_address=http://mattnelsoninfo.files.wordpress.com/2008/04/ceiling_cat1.jpg
NOTA:gd è elencato nell'output di phpinfo().
MODIFICARE:Sto usando PHP versione 5.2.6-2ubuntu4.1
Un altro EDIT:
phpinfo() lo restituisce nella sezione 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
Grazie!
Soluzione
Quale versione di PHP stai usando? Sembra ImageFilter è una funzione PHP5 ... http: //us3.php .net / manuale / it / function.imagefilter.php
EDIT: Il tuo codice funziona sulla mia versione di PHP. Per avere un riferimento, ecco la mia 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
Si potrebbe desiderare di fare in modo che la versione GD è in bundle. Ho visto le installazioni che dicono GD Support è attivato ma non in bundle. Non sono sicuro se questo fa la differenza però.
Altri suggerimenti
ImageFilter sembra essere disponibile solo se PHP è compilato agains la libreria GD bundle che nel tuo caso non è (che è la differenza tra il bundle e attivato). Dal momento che si sta utilizzando Ubuntu la versione di PHP che si trova nel repository non hanno Gd in bundle.
http://www.php.net/manual/en/function.imagefilter.php c'è un avviso:
Nota:Questa funzione è disponibile solo se PHP viene compilato con la versione in bundle della libreria GD.
Proprio come un aggiornamento del 2016, PHP 5.3 ha permesso GD esterno da utilizzare, ma questo non ha funzionato per qualche ragione in lucida / preciso. fidato, con PHP 5.5, non hanno tutte queste funzioni immagine lavorativi tranne imageantialias, fonte https://bugs.launchpad.net/ubuntu/+source/php5/+bug/74647/comments/61 (e commenti precedenti).