php图像处理_php图像处理简单实例

更新时间:2016-11-21    来源:图像处理    手机版     字体:

【www.bbyears.com--图像处理】

imagecreatetruecolor()返回一个图像标识符代表指定大小的黑色形象。

根据你的php教程和gd版本中函数定义与否。对于php 4.0.6通过4.1.x这个函数总是存在的


*/
$im=imagecreatetruecolor(100,100);        //创建图像
$string="n";            //定义字符
$white=imagecolorallocate($im,255,255,255);      //定义白色
$black=imagecolorallocate($im,0,0,0);       //定义黑色
$red=imagecolorallocate($im,255,0,0);       //定义红色
//在白色的背景上输出一个黑色的"z",其实是颠倒的n
imagecharup($im,6,20,20,$string,$white);
imagechar($im,2,40,40,"r",$red);        //使用红色画出字符
header("content-type: image/png");        //输出头部信息
imagepng($im);            //输出png文件
imagedestroy($im);         //销毁图像

//

$img=imagecreatetruecolor(400,400);      //创建图像
$white=imagecolorallocate($img,255,255,255);     //定义白色
$black=imagecolorallocate($img,0,0,0);      //定义黑色
imagearc($img,200,200,350,350,0,360,$white);     //画椭圆弧
header("content-type: image/png");       //输出头信息
imagepng($img);          //输出为png图像
imagedestroy($img);          //销毁图像

//
$size=300;
$image=imagecreatetruecolor($size,$size);
//用白色背景加黑色边框画个方框
$back=imagecolorallocate($image,255,255,255);
$border=imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,0,0,$size-1,$size-1,$back);
imagerectangle($image,0,0,$size-1,$size-1,$border);
$yellow_x=100;
$yellow_y=75;
$red_x=120;
$red_y=165;
$blue_x=187;
$blue_y=125;
$radius=150;
//用alpha值分配一些颜色
$yellow=imagecolorallocatealpha($image,255,255,0,75);
$red=imagecolorallocatealpha($image,255,0,0,75);
$blue=imagecolorallocatealpha($image,0,0,255,75);
//画三个交迭的圆
imagefilledellips教程e($image,$yellow_x,$yellow_y,$radius,$radius,$yellow);
imagefilledellipse($image,$red_x,$red_y,$radius,$radius,$red);
imagefilledellipse($image,$blue_x,$blue_y,$radius,$radius,$blue);
//输出header文件头
header("content-type: image/png");
//最后输出结果
imagepng($image);
imagedestroy($image);

//

$im=imagecreate(100,100);         //创建图像
$string="php";            //定义字符串
$bg=imagecolorallocate($im,255,255,255);      //定义白色
$black=imagecolorallocate($im,0,0,0);       //定义黑色
//在左上角输出指定字符
imagechar($im,1,0,0,$string,$black);
header("content-type: image/png");        //输出头部信息
imagepng($im);            //输出png文件
imagedestroy($im);           //销毁图像

?>

本文来源:http://www.bbyears.com/jiaocheng/28456.html