-1

我已经在本地服务器和在线网络服务器上进行了测试...但返回一个空图像...

检查返回结果... http://s8.postimage.org/sthztzj5x/null_image.jpg

<?php
Set the content-type
header('Content-Type: image/png');
$im = imagecreatetruecolor(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$text = 'Testing...';
$font = 'arial.ttf';
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>
4

2 回答 2

0

此脚本的第二行导致 PHP 解析错误。像这样在它的前面添加双斜杠:

// 设置内容类型

于 2012-12-16T20:23:54.767 回答
0

这对我来说是正确的。

http://www.laprbass.com/RAY_temp_rameez.php

<?php // RAY_temp_rameez.php
error_reporting(E_ALL);

// Set the content-type
header('Content-Type: image/png');
$im = imagecreatetruecolor(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$text = 'Testing...';
$font = 'fonts/verdanaz.ttf';
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
于 2012-12-16T20:29:42.957 回答