php 给图片添加文字或图片 并实现保存,,急救!!

如题所述

简单说,这就是PHP的一个生成水印的功能了。
直接帖代码给你。并附上注释吧,应该能看懂。

<?php
header("Content-type: image/jpeg");    //浏览器输出,如不需要可去掉此行
$im = @imagecreatefromjpeg('test.jpg');    //从图片建立文件,此处以jpg文件格式为例
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$text = 'Testing...'; //要写到图上的文字
$font = 'arial.ttf'; //写的文字用到的字体。
$srcw=imagesx($im);
imagettftext($im, 20, 0, $srcw-210, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagettftext($im, 20, 0, 9, 19, $white, $font, $text);
imagepng($im);
imagedestroy($im);
?>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-11-10
你可以去PHP100上面找找!有这方面的视频教程!
相似回答