我有完全相同的问题,因为这SO,不幸的是没有收到任何答案: PHP GD - Empty boxPHP GD图像库显示空盒/破碎的形象
我想开始使用PHP GD图像库,试图运行documentation for imagecreate的示例代码。我正在使用Mercury Vagrant (HGV)进行测试。
实施例:
<?php
header("Content-Type: image/png");
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
运行此产生一个断开的图像或空框用实线边框。在开发人员控制台的唯一信息是:
资源解释为文献但与MIME类型 图像/ PNG移送:“http://hhvm.hgv.test/stats/”。导航到 http://hhvm.hgv.test/stats/
卸下上面的代码并插入一个if语句来检查GD库显示它正在安装。
GD检查:
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "PHP GD library is installed on your web server";
} else {
echo "PHP GD library is NOT installed on your web server";
}
输出:
“PHP GD库安装在Web服务器上”