1. <?php
  2. //imagefilledellipse — 画一椭圆并填充
  3. /*bool imagefilledellipse ( resource $image , int $cx , int $cy , int $w , int $h , int $color )
  4. $image:图片资源
  5. $cx:左边离圆心的位置
  6. $cy:上边离圆心的位置
  7. $w:圆形的直径(左右方向)
  8. $h:圆形的直径(上下方向)
  9. $color:填充的颜色
  10. $im = imagecreatetruecolor(100,100);
  11. $red = imagecolorallocate($im,0,255,0);
  12. imagefilledellipse($im,50,50,80,80,$red);
  13. header('Content-type: image/png');
  14. imagepng($im);
  15. */
  16.  
  17. //imagefilledpolygon — 画一多边形并填充
  18. /*bool imagefilledpolygon ( resource $image , array $points , int $num_points , int $color )
  19. $image:图片资源
  20. $points:参数是一个按顺序包含有多边形各顶点的 x 和 y 坐标的数组
  21. $num_points:参数是顶点的总数,必须大于 3
  22. $color:颜色
  23. $im = imagecreatetruecolor(200,200);
  24. $value = array( 25,40,36,53,87,12,45,98,56,23);
  25. $red = imagecolorallocate($im,255,0,0);
  26. imagefilledpolygon($im,$value,5,$red);
  27. header('Content-type: image/png');
  28. imagepng($im);
  29. */
  30.  
  31. //imagefilledrectangle — 画一矩形并填充
  32. /*bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
  33. $image:图片资源
  34. $x1:点到左边的距离
  35. $y1:点到上边的距离
  36. $x2:点到左边的距离
  37. $y2:点到上边的距离
  38. $color:填充的颜色
  39. $im = imagecreatetruecolor(200,200);
  40. $red = imagecolorallocate($im,255,0,0);
  41. imagefilledrectangle($im,10,10,190,190,$red);
  42. header('Content-type:image/png');
  43. imagepng($im);
  44. */
  45.  
  46. //imagefontheight — 取得字体高度
  47. /*$font_size = 1;
  48. $a = imagefontheight($font_size);
  49. echo $a;
  50. */
  51.  
  52. //imagefontwidth — 取得字体宽度
  53. /*$font_size = 1;
  54. $b = imagefontwidth($font_size);
  55. echo $b;
  56. */
  57.  
  58. //imageline — 画一条线段
  59. /*bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
  60. $image:图片资源
  61. $x1:点到左边的距离
  62. $y1:点到上边的距离
  63. $x2:点到左边的距离
  64. $y2:点到上边的距离
  65. $color:线段的颜色
  66. $im = imagecreatetruecolor(200,200);
  67. $red = imagecolorallocate($im,255,0,0);
  68. imageline($im,10,10,100,100,$red);
  69. header('Content-type:image/png');
  70. imagepng($im);
  71. */
  72.  
  73. //imagepolygon — 画一个多边形
  74. /*bool imagepolygon ( resource $image , array $points , int $num_points , int $color )
  75. $image:图片资源
  76. $points:参数是一个按顺序包含有多边形各顶点的 x 和 y 坐标的数组
  77. $num_points:是顶点的总数。大于3
  78. $color:线段的颜色
  79. $im = imagecreatetruecolor(200,200);
  80. $red = imagecolorallocate($im,255,0,0);
  81. $value = array(13,45,23,56,23,45,78,99);
  82. imagepolygon($im,$value,4,$red);
  83. header('Content-type:image/png');
  84. imagepng($im);
  85. */
  86.  
  87. //imagerectangle — 画一个矩形
  88. /*bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )
  89. $image:图片资源
  90. $x1:点到左边的距离
  91. $y1:点到上边的距离
  92. $x2:点到左边的距离
  93. $y2:点到上边的距离
  94. $col:线段的颜色
  95. $im = imagecreatetruecolor(200,200);
  96. $red = imagecolorallocate($im,255,0,0);
  97. imagerectangle($im,10,10,100,100,$red);
  98. header('Content-type:image/png');
  99. imagepng($im);
  100. */
  101.  
  102. //imagerotate — 用给定角度旋转图像
  103. /*resource imagerotate ( resource $src_im , float $angle , int $bgd_color [, int $ignore_transparent ] )
  104. $src_im:资源图片
  105. $angle:旋转的度数
  106. $bgd_color:背景颜色
  107. $source = imagecreatefromjpeg('1.jpg');
  108. $rotate = imagerotate($source,45, 26);
  109. header('Content-type: image/jpeg');
  110. imagejpeg($rotate);
  111. */
  112.  
  113. //imagesetpixel — 画一个单一像素
  114. /*bool imagesetpixel ( resource $image , int $x , int $y , int $color )
  115. $image:图片资源
  116. $x:点到左边的距离
  117. $y:点到上边的距离
  118. $color:点的颜色
  119. $im = imagecreatetruecolor(100,100);
  120. $red = imagecolorallocate($im,255,0,0);
  121. imagesetpixel($im,50,50,$red);
  122. header('Content-type: image/jpeg');
  123. imagejpeg($im);
  124. */
  125.  
  126. //imagesetstyle — 设定画线的风格
  127. /*bool imagesetstyle ( resource $image , array $style )
  128. $image:图片资源
  129. $style:style 参数是像素组成的数组。下面的示例脚本在画布上从左上角到右下角画一行虚线:
  130. header("Content-type: image/jpeg");
  131. $im = imagecreatetruecolor(100, 100);
  132. $w = imagecolorallocate($im, 255, 255, 255);
  133. $red = imagecolorallocate($im, 255, 0, 0);
  134. $style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
  135. imagesetstyle($im,$style);
  136. imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);
  137. imagejpeg($im);
  138. imagedestroy($im);
  139. */
  140.  
  141. //imagestring — 水平地画一行字符串
  142. /*bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
  143. $image:图片资源
  144. $font:字体大小
  145. $x:文字到左边的距离
  146. $y:文字到上边的距离
  147. $s:文字内容
  148. $col:文字颜色
  149. $im = imagecreatetruecolor(100,100);
  150. $red = imagecolorallocate($im, 255, 0, 0);
  151. imagestring($im,5,10,10,'helloworld',$red);
  152. header("Content-type: image/jpeg");
  153. imagejpeg($im);
  154. imagedestroy($im);
  155. */
  156.  
  157. //imagestringup — 垂直地画一行字符串
  158. /*bool imagestringup ( resource $image , int $font , int $x , int $y , string $s , int $col )
  159. $image:图片资源
  160. $font:字体大小
  161. $x:文字到左边的距离
  162. $y:文字到上边的距离
  163. $s:文字内容
  164. $col:文字颜色
  165. $im = imagecreatetruecolor(100,100);
  166. $red = imagecolorallocate($im, 255, 0, 0);
  167. imagestringup ($im,5,20,90,'helloworld',$red);
  168. header("Content-type: image/jpeg");
  169. imagejpeg($im);
  170. imagedestroy($im);
  171. */
  172.  
  173. //imagesx — 取得图像宽度
  174. /*$im = imagecreatetruecolor(200,100);
  175. echo imagesx($im);
  176. */
  177.  
  178. //imagesy — 取得图像长度
  179. /*$im = imagecreatetruecolor(200,100);
  180. echo imagesy($im);
  181. */
  182.  
  183. //imagegd2 — 将 GD2 图像输出到浏览器或文件
  184. //imagegd — 将 GD 图像输出到浏览器或文件
  185. //imagegif — 以 GIF 格式将图像输出到浏览器或文件
  186. //imagejpeg — 以 JPEG 格式将图像输出到浏览器或文件
  187. //imagepng — 以 PNG 格式将图像输出到浏览器或文件
  188. //imagewbmp — 以 WBMP 格式将图像输出到浏览器或文件
  189. //imagexbm — 将 XBM 图像输出到浏览器或文件
  190. /*以上都是函数如果有第二个参数那么会保存到文件上,如果没有第二个参数则会输出到浏览器上*/
  191.  
  192. ?>

php-GD库函数(三)的更多相关文章

  1. PHP的GD库函数大全

    GetImageSize作用:取得图片的大小[即长与宽]  用法:array GetImageSize(string filename, array [imageinfo]); ImageArc作用: ...

  2. Linux 文件管理(C语言库函数三)

    找到当前目录 char *getcwd(char * buf,size_t size) getcwd函数把当前工作目录的绝对路径名复制到buf中,size指示buf的大小 如果buf不够大,不能装下整 ...

  3. PHP中GD库函数

    画椭圆弧 imagearc($image,$cx,$cy,$width,$height,$angel1,$angel2,$color) 注释:$image 图像资源   $cx  椭圆中心点的水平位置 ...

  4. React-Native 之 GD (三)近半小时热门

    1.设置页面跳转 半小时热门组件  GDHalfHourHot.js /** * 近半小时热门 */ import React, { Component } from 'react'; import ...

  5. PHP扩展使用-GD

    一.相关函数 1. 获取信息 gd_info() #查看当前系统环境gd库支持的图片格式 getimagesize(imagefile) #获取图像大小,非GD库函数 imagex(imagefile ...

  6. PHP5 GD库生成图形验证码(汉字)

    PHP5 GD库生成图形验证码且带有汉字的实例分享. 1,利用GD库函数生成图片,并在图片上写指定字符imagecreatetruecolor 新建一个真彩色图像imagecolorallocate ...

  7. PHP图片处理之图片背景、画布操作

    像验证码或根据动态数据生成统计图标,以及前面介绍的一些GD库操作等都属于动态绘制图像.而在web开发中,也会经常去处理服务器中已存在的图片.例如,根据一些需求对图片进行缩放.加水印.裁剪.翻转和旋转等 ...

  8. 关于PHP批量图片格式转换的问题--本文转成webp, 其他过程格式一样

    最近要把项目中的图片全部生成webp格式, 过程整理一下,    (直接存在本地,或者图片链接存在数据库都可以看看) 首先,肯定是批量处理, 一个php处理不了这么多, 会爆内存的, 个人建议用aja ...

  9. PHP14 动态图像处理

    学习要点 如何使用PHP中的GD库 设计验证码类 PHP图片处理 设计图像图处理类 如何使用PHP中的GD库 在网站上GD库通常用来生成缩略图,或者用来对图片加水印,或者用来生成汉字验证码,或者对网站 ...

随机推荐

  1. Cocos2d-x CCProgressTimer

    CCProgressTimer,创建使用这个节点可以大致实现两个作用的效果: 其一:在游戏中几乎大部分的游戏启动界面都是游戏加载画面,那么用到的一般是进度条提示加载进度,其使用的就是CCProgres ...

  2. 在toolbar里动态创建多个button(ext.net)

    private void setOneMenu() { string sql = "select id,name,gids from Config where name<>'高级 ...

  3. Swift - 自定义单元格实现微信聊天界面

    1,下面是一个放微信聊天界面的消息展示列表,实现的功能有: (1)消息可以是文本消息也可以是图片消息 (2)消息背景为气泡状图片,同时消息气泡可根据内容自适应大小 (3)每条消息旁边有头像,在左边表示 ...

  4. Swift - 开关按钮(UISwitch)的用法

    下面演示如何创建开关,以及监听它值的改变,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class ViewController: UIV ...

  5. Android学习4、Android该Adapter

    一.Adapter介绍 An Adapter object acts as a bridge between an AdapterView and the underlying data for th ...

  6. NET Core 中的依赖注入

    NET Core 中的依赖注入 [共7篇] 一.控制反转(IoC) ASP.NET Core在启动以及后续针对每个请求的处理过程中的各个环节都需要相应的组件提供相应的服务,为了方便对这些组件进行定制, ...

  7. Delphi 类与对象内存结构浅析(三篇)

    http://blog.csdn.net/starsky2006/article/details/5497082 http://blog.csdn.net/starsky2006/article/de ...

  8. [C++]Hello C++

    最先进项目中需要用到C++做开发,所以开始学习C++,典型的眼高手低,刚开始觉得还算上手,之后越学越觉得复杂. 相比C#,C++确实需要开发者投入更多的精力去设计与维护. 以下是最近对C++开发的一些 ...

  9. HashTable的数组和连接两种实现方法(Java版本号)

    1.散列表的接口类 package cn.usst.hashtable; /** * 散列表的接口类 * @author G-Xia * */ public interface HashTable { ...

  10. hdu3790最短路径问题 (用优先队列实现的)

    Problem Description 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的.   Inp ...