问题
I'm having a strange behavior with PHP, GD, and libJPEG
Here is my phpinfo() for GD:
GD Support enabled
GD Version bundled (2.0.34 compatible)
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 8
PNG Support enabled
libPNG Version 1.2.44
WBMP Support enabled
XBM Support enabled
This is what I'm doing :
$img = imagecreatefromjpeg("/home/logo.jpg");
var_dump($img)
Result is false. Image exists, and is chmodded 777.
I'm running php 5.3.9, also make test FAILED on JPEG <-> png conversions and others JPEG operations.
Any ideas? Thanks!
SOLUTION FOUND : remove --disable-rpath from ./configure. And now I'm going to take a gun and shot me in the head.
回答1:
run
$data = getimagesize("/home/logo.jpg");
var_dump($data);
and make sure that the MIME TYPE of the image is image/jpeg
another reason might be that the path to the file is not true (maybe you need to remove the starting "/" and leave only imagecreatefromjpeg("home/logo.jpg")
[if the home directory is in the same level as your php file - than you should]
来源:https://stackoverflow.com/questions/8953333/gd-libjpeg-loaded-imagejpeg-returns-false