GD, libJPEG loaded, imagejpeg returns false

主宰稳场 提交于 2019-12-13 06:11:31

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!