PHP 常用函数(二)

12个常用图像处理

函数名描述实例输入输出操作
imagecreatetruecolor新建一个真彩色图像$im = @imagecreatetruecolor(50, 100)resource imagecreatetruecolor ( int x_size, int y_size )返回一个图像标识符,代表了一幅大小为 x_size 和 y_size 的黑色图像。
imagecolorallocate为一幅图像分配颜色$background = imagecolorallocate($im, 255, 0, 0);int imagecolorallocate ( resource image, int red, int green, int blue )返回一个标识符,代表了由给定的 RGB 成分组成的颜色。
imagefill区域填充imagefill($img,0,0,$white)bool imagefill ( resource image, int x, int y, int color )在 image 图像的坐标 x,y(图像左上角为 0, 0)处用 color 颜色执行区域填充(即与 x, y 点颜色相同且相邻的点都会被填充)。
imagefilledarc画一椭圆弧且填充imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE);bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )在 image 所代表的图像中以 cx,cy(图像左上角为 0, 0)画一椭圆弧。如果成功则返回 TRUE,失败则返回 FALSE。w 和 h 分别指定了椭圆的宽和高,s 和 e 参数以角度指定了起始和结束点。
imagefilledellpse画一椭圆并填充imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse);bool imagefilledellipse ( resource image, int cx, int cy, int w, int h, int color )在 image 所代表的图像中以 cx,cy(图像左上角为 0, 0)为中心画一个椭圆。w 和 h 分别指定了椭圆的宽和高。椭圆用 color 颜色填充。如果成功则返回 TRUE,失败则返回 FALSE。
imagefilledrectangle画一矩形闭关填充imagefilledrectangle($image, 200, 150, 300, 200, $col_ellipse);bool imagefilledrectangle ( resource image, int x1, int y1, int x2, int y2, int color )在 image 图像中画一个用 color 颜色填充了的矩形,其左上角坐标为 x1,y1,右下角坐标为 x2,y2。0, 0 是图像的最左上角。
imagestring水平地画一行字符串imagestring($im, 5, 0, 0, “Hello world!”, $textcolor);bool imagestring ( resource image, int font, int x, int y, string s, int col )用 col 颜色将字符串 s 画到 image 所代表的图像的 x,y 坐标处(这是字符串左上角坐标,整幅图像的左上角为 0,0)。如果 font 是 1,2,3,4 或 5,则使用内置字体。
imagestringup垂直地画一行字符串imagestringup($im,5,0,0,"Hello world!",$white)bool imagestringup ( resource image, int font, int x, int y, string s, int col )
imagegettftext用 TrueType 字体向图像写入文本imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);array imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )image 图片资源,size字体大小,angle角度,x第一个字符的水平坐标,y第一个字符的垂直坐标,color颜色索引,fontfile使用的TrueType字体路径,text文本字符串
imagepng以 PNG 格式将图像输出到浏览器或文件$im = imagecreatefrompng("test.png"); imagepng($im);bool imagepng ( resource image [, string filename] )将 GD 图像流(image)以 PNG 格式输出到标准输出(通常为浏览器),或者如果用 filename 给出了文件名则将其输出到该文件。
imagecopyresampled重采样拷贝部分图像并调整大小imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);bool imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )将一幅图像中的一块正方形区域拷贝到另一个图像中,平滑地插入像素值,因此,尤其是,减小了图像的大小而仍然保持了极大的清晰度。如果成功则返回 TRUE,失败则返回 FALSE。
imagedestory销毁一图像imagedestory($im)bool imagedestroy ( resource image )释放与 image 关联的内存。image 是由图像创建函数返回的图像标识符,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值