美文网首页
PHP---GD库

PHP---GD库

作者: 大菜鸟呀 | 来源:发表于2018-08-18 13:49 被阅读0次

基本画图步骤:

<?php
//1、创建画布
$img=imagecreatetruecolor(300, 200);
//2、创建颜色
$bcak=imagecolorallocate($img, 0, 255, 0);
//3、填充画布
imagefill($img, 0, 0, $bcak);
//4、输出最终图像或保存最终图像
header('content-type:image/jpeg');
imagejpeg($img,);//输出图像
imagejpeg($img,'jin.jpg'); //保存图像
//5、释放画布资源
imagedestroy($img);
 ?>

绘制图像的方法:

绘制图像的方法:
绘制一个像素点:imagesetpixel(image, x, y, color)
绘制一条线:imageline(image, x1, y1, x2, y2, color);
绘制一个矩形:imagerectangle(image, x1, y1, x2, y2, color);
绘制一个矩形并填充:imagefilledrectangle(image, x1, y1, x2, y2, color);

绘制一个多边形:imagepolygon(image, points, num_points, color)
绘制一个多边形并填充:imagefilledpolygon(image, points, num_points, color)

绘制一个椭圆:imageellipse(image, cx, cy, width, height, color)
绘制一个椭圆并填充:imagefilledellipse(image, cx, cy, width, height, color)

绘制一个椭圆弧,并填充:imagefilledarc(image, cx, cy, width, height, start, end, color, style)
 

水平地画一行字符串:imagestring(image, font, x, y, string, color)
垂直地画一行字符串:imagestringup(image, font, x, y, string, color)

水平地画一个字符:imagechar(image, font, x, y, c, color)
垂直地画一个字符:imagecharup(image, font, x, y, c, color)

用truetype字符向图像画一个字符串:imagettftext(image, size, angle(角度), x, y, color, fontfile, text)

图片裁切和缩放

<?PHP
$img1=imagecreatefromjpeg(filename);
$img2=imagecreatetruecolor(150, 100);
imagecopyresampled(dst_image, src_image, dst_x, dst_y, src_x, src_y, dst_w, dst_h, )

dst_image:目标图片
src_image:原图片

dst_x、dst_y:

src_x, src_y:

dst_w, dst_h:

src_w, src_h:
?>

相关文章

  • PHP---GD库

    基本画图步骤: 绘制图像的方法: 图片裁切和缩放

  • 公司数据库逻辑

    pro库 drds库 通道库 查询库 pg库 bi库 tidb库 odps查询 pro库和drds库是线上数据库 ...

  • Lua库函数概览

    Lua库函数概览数学库 table库 字符串库 IO库 os库 调试库

  • Swift 静态库调研

    一、关于库的背景知识1、静态库和动态库静态库动态库系统动态库Cocoa Touch Framework静态库 v....

  • iOS 创建静态库(.a)

    静态库(.a) 文章类型: 学习笔记 1. 静态库简介 库的概念: 什么是库? 库的分类: 库的存在形式: 静态库...

  • 目录一、库二、静态库、动态库、Framework三、打包静态库 1、.a静态库和.framework静态库的区别 ...

  • iOS 静态库和动态库的制作

    静态库和动态库 一、静态库和动态库的存在形式 静态库: .a 和 .framework 动态库: .dylib 和...

  • 动态库与静态库相互连接

    动态库--动态库 场景:App --> 动态库A --> 动态库 B 存在问题:动态库B应该的路径 = 动态库A的...

  • Python解析库

    Python解析库 目录一、lxml库二、BeautifulSoup库三、PyQuery库 一、lxml库 教程:...

  • HCMediator组件化详解

    组件化创建流程库 组件化需要创建私有spec库(索引库)、HCMediator库(App中介库)、其他组件库 私有...

网友评论

      本文标题:PHP---GD库

      本文链接:https://www.haomeiwen.com/subject/nolfiftx.html