GD库常用函数

Posted Docter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GD库常用函数相关的知识,希望对你有一定的参考价值。

创建句柄

  • imagecreate($width, $height)                                                  //新建图像
  • imagecreatefromjpeg($path)                                               //打开已有的图像

  • imagecreatefromgif($path)

  • imagecreatefrompng($path)

getimagesize($path)                        //获取图像信息

imagecopyresampled($newImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);// 创建缩略图

imagearc($image, $cx, $cy, $width, $height, $start, $end, $color) //创建圆

imagestring($image, $font, $x, $y, $string, $color)        //水平绘制字符串

imagestringup($image, $font, $x, $y, $string, $color)      //垂直绘制字符串

$color= imagecolorallocate($image, $red, $green, $blue)     //设置图像颜色

imagefilledrectangle($image, 0, 0, 100, 100, $white);       //矩形填充

header("Content-type: image/png");

imagepng($image);                        //输出png图像(jpeg/gif)

imagedestroy($image)                       //关闭句柄

imagecopymerge($dst, $src, 10, 10, 0, 0, $src_w, $src_h, 50);   //图片叠加

用法:创建验证码,图片添加水印,创建缩略图等

 

以上是关于GD库常用函数的主要内容,如果未能解决你的问题,请参考以下文章

了解GD2函数库

调用未定义的函数 imagecreatefromjpeg() GD 已安装但无法识别

介绍常用的OpenGL的函数(定义+功能)

c++的algorithm库常用函数

c语言常用库函数都有哪些

什么是C语言标准函数库?平常用的哪些函数属于标准函数库?