因为收藏上的太详细了。http://cn.php.net/manual/zh/ref.image.php例子 1. imagettftext() 例子本例中的脚本将生成一个白色的 400x30 像素 PNG 图像,其中有黑色(带灰色阴影)Arial 字体写的“Testing...”。
<?php
// Set the content-type
header("Content-type: image/png");// Create the image
$im = imagecreatetruecolor(400, 30);// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
<?php
// Set the content-type
header("Content-type: image/png");// Create the image
$im = imagecreatetruecolor(400, 30);// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
<div></div>
你可以看下HTML中的DIV用法
我是想在现有的图片上加水印,不是自己创建一个图片