
<?php
header("Content-type: image/png")
$string = $_GET['text']
$im = imagecreatefrompng("images/button1.png")
$orange = imagecolorallocate($im, 220, 210, 60)
$px = (imagesx($im) - 7.5 * strlen($string)) / 2
imagestring($im, 3, $px, 9, $string, $orange)
imagepng($im)
imagedestroy($im)
?>
本例程需要从带有 <img src="button.php?text=text">标签的页面调用。 上述 button.php 脚本将 "text" 字符串绘制到一个图像上, 在本例中图像文件为 "images/button1.png", 然后输出绘制后的图像。 当你需要经常修改图像上的文字时, 动态生成图像就可以省去了每次都重新制作图像的麻烦。
其实你为什么非要BYTE格式处理呢,作图之类应该交给PS等软件,不过楼主硬是要一个例子,请看下面代码:<?
if(!file_exists('test.jpg'))
{
fopen('test.jpg')
}
$fp = fopen('test.jpg', 'w')
fwrite($fp, $byte)
fclose($fp)
header ("Content-type: image/jpg")
echo $byte
?>
imagechar() 将字符串 c 的第一个字符画在image 指定的图像中,其左上角位于 x,y(图像左上角为 0, 0),颜色为 color。如果
font 是 1,2,3,4 或 5,则使用内置的字体(更大的数字对应于更大的字体)。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)