php图像处理


<?php
/*
创建图片
imagecreate — 新建一个基于调色板的图像
	resource imagecreate ( int $x_size , int $y_size )

imagecreatetruecolor 新建一个真彩色图像
	resource imagecreatetruecolor ( int $x_size , int $y_size )


图像分配颜色
imagecolorallocate — 为一幅图像分配颜色
	int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
imagecolorallocatealpha — 为一幅图像分配颜色 + alpha(透明度,1-127)
	int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
bool imagecolordeallocate ( resource $image , int $color ) 取消图像颜色的分配


在图片上画东东
imageline — 画一条线段
bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
imagestring — 水平地画一行字符串
	bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )

imageloadfont — 载入一新字体
	int imageloadfont ( string $file )
	
	
	
输出图像
imagepng — 以 PNG 格式将图像输出到浏览器或文件
	bool imagepng ( resource $image [, string $filename ] )
imagegif(),imagewbmp(),imagejpeg() 和 imagetypes()。


销毁一图像
imagedestroy — 销毁一图像、
	bool imagedestroy ( resource $image )
	
取得图像大小
array getimagesize ( string $filename [, array &$imageinfo ] )
	eg:getimagesize("img/flag.jpg");  getimagesize("http://www.example.com/gifs/logo.gif");
	
int imagesx ( resource $image ) - 取得图像宽度
int imagesy ( resource $image ) — 取得图像高度

*/


// 建立一幅图像 大小:100X30
//$im = imagecreatefrompng('bg.png');
$im = imagecreate(100, 30);

// 填充背景 白色背景和蓝色文本
$bg				 = imagecolorallocate($im, 155, 155, 155);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// 把字符串写在图像左上角
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);

// 输出图像
header("Content-type: image/png");
imagepng($im);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值