PHP JPEG功能不起作用 [英] PHP JPEG Functions Not Working

查看:111
本文介绍了PHP JPEG功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何处理JPEG的PHP函数似乎都无法在我的服务器上正常工作.

Any PHP functions that deal with JPEGs don't seem to be working on my server.

此代码:

<?php
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>

创建一个空文件.

使用GIF或PNG函数将创建一个包含文本"A Simple Text String"的图像.

Using a GIF or PNG function will create an image containing the text "A Simple Text String" as expected.

此:

$im = imagecreatefromjpeg("test.jpg");

返回

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'test.jpg' is not a valid JPEG file in /path/to/test.php on line 2

一个phpinfo()显示:

A phpinfo() shows:

gd
GD Support  enabled
GD Version  2.0 or higher
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.3.9
T1Lib Support   enabled
GIF Read Support    enabled
GIF Create Support  enabled
JPG Support     enabled
PNG Support     enabled
WBMP Support    enabled 

Web服务器可以读取任何相关文件.

And the webserver can read any relevant files.

GIF和PNG函数可以正常工作,并且符合预期.

GIF and PNG functions work fine, and as expected.

有什么想法吗?

在我的Apache错误日志文件中找到了它:

Found this in my Apache error log file:

gd-jpeg: JPEG library reports unrecoverable error: Wrong JPEG library version: library is 80, caller expects 62

推荐答案

您的错误日志清楚地表明,您的PHP是针对/c的libjpeg版本62编译的,而服务器上的库是版本80的.

Your error log clearly shows that your PHP is compiled against/requires libjpeg version 62, while the library on your server is version 80.

要么安装正确版本的libjpeg,要么重新编译gd/php.

Either install the correct version of libjpeg, or recompile gd/php.

这篇关于PHP JPEG功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆