i've testing on localserver and online web server... but return a null image...

check return result... 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);
?>
有帮助吗?

解决方案

This worked correctly for me.

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);

其他提示

The second line of this script causes a PHP parse error. Add double slashes to the front of it like this:

// Set the content-type

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top