php 图片处理函数

记录一些图片处理函数 防止自己老是忘记  有空的时候可以多看看

 

<?php
//header('Content-Type:text/html;charset=utf-8');
//图像处理
//1 设置MIME类型  输出类型  text/html 默认是网页类型 可以不写

header('Content-Type:image/png;');

$width = 400;
$height = 400;
//2 创建一个图像区域   宽度  高度
$img = imagecreatetruecolor($width,$height);

//为图像分配颜色  句柄  红 绿  烂
$blue = imagecolorallocate($img,0,102,255);

//填充颜色  资源句柄  x轴  y轴  颜色
imagefill($img,0,0,$blue);

//继续创建颜色   
$while = imagecolorallocate($img,255,255,255);

//画一个线条  句柄 x开始  y开始 x结束 y结束  颜色
imageline($img,60,90,90,60,$while);


//打印图片信息
getimagesize($img);


//绘制文本   句柄   字体大小 x轴  y轴  内容  颜色
imagestring($img,5,0,0,'wwwww',$while);



//载入图片  list()  这个函数不错
imagecreatefrompng('22.png');


//原图从新采样 拷贝到新图上  
//新图句柄  原图句柄     新图xy  原图 xy  新图长高  原图长高
imagecopyresampled($img,$yuan,40,40,0,0,$_width,$_height,$width,$height);


//输出图片
imagepng($img);
//销毁句柄
imagedestroy($img);




?>

 

posted @ 2012-06-25 10:26  梁天  阅读(1113)  评论(0编辑  收藏  举报