这个是要你图片分三段,左右为图片,中间作为背景,css里设他为横向重复,添加文字
解决方案 »
- 关于call_user_func_array 和 引用 的一段代码 不懂求解释
- apache怎样将域名绑定到非80端口?
- ISAPI_Rewrite 防盗链的正则问题. 150分(全部的分都压上了)
- 如何用php向服务器已存在的zip文件中增加一个文件
- PHP日期的运算问题,在线等急啊
- 活跃思路:php做小游戏思路和原理探究——象棋
- 有没有广州的PHPer在找工作呢?
- php session 问题
- 在VC MFC中怎样实现从菜单的一个选项链接到一个.EXE文件?急!!分多!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 网络办公系统(PHP)
- 生成png图片的问题
- 【仅限深圳本地】PHP高手来——付费建站&长期兼职合作!
http://hk2.php.net/manual/en/function.imagepsbbox.php
http://hk2.php.net/manual/en/function.imagettfbbox.php根据你的需要用上面三个函数的其中一个获取你的文字在图片上绘制的大小,然后调整画布。
http://hk2.php.net/manual/en/function.imagettfbbox.php$bbox = imagettfbbox(10, 45, './arial.ttf', 'www.mikespook.com');$bbox 得到一个8元素长数组分别表示了文字下左、下右、上右、上左的坐标。
简单的说,就是文字绘制在画布上时,你用一个边和画布边平行的最小的长方形框住的位置。
那么你可以用这组坐标计算出文字实际的宽高,然后用这个宽高创建画布,绘制文字在坐标 0,0 即可~~细节,打开画板什么的用鼠标画画很容易明白。
$im = imagecreatefrompng("test.png");
$srcW=ImageSX($im);
$srcH=ImageSY($im);$ni=ImageCreate(400,$srcH);
imagecopyresampled($ni,$im,0,0,0,0,400,$srcH,$srcW,$srcH);$str_width = imagettfbbox(9, 0, "tahoma.ttf", $str);
$str_start = (200 - ($str_width[2] + 113));
$color = imagecolorallocate($ni, 164, 164, 164);
imagettftext($ni, 9, 0, $str_start, 16, $color, "tahoma.ttf", $str);
imagepng($ni);
imagedestroy($ni);我的代码是这样写的,虽然画布宽了,但图片中图案被拉长变形了
$ni=ImageCreate($str_width[2] - $str_width[0], $srcH); // 再根据宽度创建图片
http://services.nexodyne.com/email/index.php图片的宽度随输入的“用户名”字符的数目而变化,字数多则宽度变大,字数少则宽度便变小,但右侧“@gmail.com"的图案尺寸不变
<?php
$str="test1";$im = imagecreatefrompng("test.png");$srcW=ImageSX($im);
$srcH=ImageSY($im);$str_width = imagettfbbox(9, 0, "tahoma.ttf", $str);
$ni=imagecreatetruecolor($str_width[2] - $str_width[0] + $srcW, $srcH);
imagefill($ni, 0, 0, imagecolorallocate($ni, 255, 255, 255));imagecopyresampled($ni,$im, abs($str_width[2] - $str_width[0]),0,0,0,$srcW,$srcH,$srcW,$srcH);$color = imagecolorallocate($ni, 0, 0, 0);
imagettftext($ni, 9, 0, 0, abs($str_width[7] - $str_width[1]), $color, "tahoma.ttf", $str);imagepng($ni, "test1.png");
imagedestroy($ni);