这个可以改下代码和原图,把原图的日期P掉,然后在toutu.php文件中的第12行加入以下代码:- $date=date("Y年m月d日");
- $text=$date;
- imagettftext($im, 16, 0, 214, 225, $black, $font, $text);
复制代码
其中第五个参数 225,为我的目测数值,具体看生成的日期偏上还是偏下自己微调以下
最后得到的代码如下:
- <?php
- header("content-type:image/jpeg");
- $name = $_GET['name']?$_GET['name']:"顶级源码";
- $im = imagecreatetruecolor(580, 742);
- $bg = imagecreatefromjpeg('toutu.jpg');
- imagecopy($im,$bg,0,0,0,0,580,742);
- imagedestroy($bg);
- $black = imagecolorallocate($im, 131, 117, 108);
- $text = $name;
- $font = 'msyh.ttf';
- imagettftext($im, 16, 0, 214, 195, $black, $font, $text);
- $date=date("Y年m月d日");
- $text=$date;
- imagettftext($im, 16, 0, 214, 225, $black, $font, $text);
- imagejpeg($im);
- imagedestroy($im);
- ?>
复制代码
|