任何处理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);
?>
Run Code Online (Sandbox Code Playgroud)
创建一个空文件.
使用GIF或PNG函数将按预期创建包含文本"A Simple Text String"的图像.
这个:
$im = imagecreatefromjpeg("test.jpg");
Run Code Online (Sandbox Code Playgroud)
回报
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'test.jpg' is not a valid JPEG file in /path/to/test.php on line 2
Run Code Online (Sandbox Code Playgroud)
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 …Run Code Online (Sandbox Code Playgroud)