gpt4 book ai didi

PHP JPEG 函数不工作

转载 作者:行者123 更新时间:2023-12-02 08:57:52 24 4
gpt4 key购买 nike

任何处理 JPEG 的 PHP 函数似乎都无法在我的服务器上运行。

这段代码:

<?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 函数将创建一个包含预期文本“简单文本字符串”的图像。

这个:

$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() 显示:

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

网络服务器可以读取任何相关文件。

GIF 和 PNG 函数工作正常,符合预期。

有什么想法吗?

编辑:

在我的 Apache 错误日志文件中找到此内容:

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

最佳答案

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

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

关于PHP JPEG 函数不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3477896/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com