【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了imageface.php提供大家参考,希望对大家有所帮助!
<?php
//创建图像
$im = imagecreate(100, 100);
//设置颜色
$w = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
/* 画一条虚线,5 个红色像素,5 个白色像素 */
$style = array ($red,$red,$red,$red,$red,$w,$w,$w,$w,$w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 90, 90, IMG_COLOR_STYLED);
/* 用 imagesetbrush() 和 imagesetstyle() 画一行笑脸 */
$style = array ($w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$red);
imagesetstyle($im, $style);
//从 PNG 文件或 URL 新建一图像
$brush = imagecreatefrompng("http://www.libpng.org/pub/png/images/smile.happy.png");
//设置颜色
$w2 = imagecolorallocate($brush,255,0,255);
//将$brush颜色定义为透明色
imagecolortransparent($brush, $w2);
//设定画线用的画笔图像
imagesetbrush($im, $brush);
//画一条直线
imageline($im, 90, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);
//输出图片
header("Content-type: image/jpeg");
imagejpeg($im);
//清除所有资源
imagedestroy($im);
?>