图片GD底层类¶
属性 | 值 |
---|---|
命名空间 | fize\image |
类名 | Gd |
方法: |
---|
方法名 | 说明 |
---|---|
__construct() | 初始化 |
__destruct() | 析构,释放内存 |
info() | 取得当前安装的 GD 库的信息 |
getSize() | 取得图像大小 |
getType() | 获取图片真实后缀 |
getSizeFromString() | 从字符串中获取图像尺寸信息 |
typeToExtension() | 取得图像类型的文件后缀 |
typeToMimeType() | 返回的图像类型的 MIME 类型 |
output() | 输出图像 |
affine() | 仿射变换 |
affineMatrixConcat() | 连接两个仿射变换矩阵 |
affineMatrixGet() | 得到一个仿射变换矩阵 |
alphaBlending() | 设定图像的混色模式 |
antialias() | 是否使用抗锯齿功能 |
arc() | 画椭圆弧 |
char() | 水平地画一个字符 |
charUp() | 垂直地画一个字符 |
colorAllocate() | 分配颜色 |
colorAllocateAlpha() | 分配带透明度颜色 |
colorAt() | 取得某像素的颜色索引 |
colorClosest() | 取得与指定的颜色最接近的颜色索引 |
colorClosestAlpha() | 取得与指定的颜色加透明度最接近的颜色索引 |
colorClosestHwb() | 取得与给定颜色最接近的色度的黑白色的索引 |
colorDeallocate() | 取消图像颜色分配 |
colorExact() | 取得指定颜色的索引值 |
colorExactAlpha() | 取得指定的颜色加透明度的索引值 |
colorMatch() | 使一个图像中调色板版本的颜色与真彩色版本更能匹配 |
colorResolve() | 取得指定颜色的索引值或有可能得到的最接近的替代值 |
colorResolveAlpha() | 取得指定颜色 + alpha 的索引值或有可能得到的最接近的替代值 |
colorSet() | 给指定调色板索引设定颜色 |
colorsForIndex() | 取得颜色索引的信息 |
colorStotal() | 取得一幅图像的调色板中颜色的数目 |
colorTransparent() | 将某个颜色定义为透明色 |
convolution() | 用系数 div 和 offset 申请一个 3x3 的卷积矩阵 |
copy() | 拷贝图像的一部分 |
copyMerge() | 拷贝并合并图像的一部分 |
copyMergeGray() | 用灰度拷贝并合并图像的一部分 |
copyResampled() | 重采样拷贝部分图像并调整大小 |
copyResized() | 拷贝部分图像并调整大小 |
create() | 新建一个基于调色板的图像 |
createFrom() | 从指定资源创建 |
crop() | 裁剪图像 |
cropAuto() | 使用其中一种可用模式自动裁剪图像 |
dashedLine() | 画一虚线 |
destroy() | 销毁一图像 |
ellipse() | 画一个椭圆 |
fill() | 区域填充,即与 x, y 点颜色相同且相邻的点都会被填充 |
filledArc() | 画一椭圆弧且填充 |
filledEllipse() | 画一椭圆并填充 |
filledPolygon() | 画一多边形并填充 |
filledRectangle() | 画一矩形并填充 |
fillToBorder() | 区域填充到指定颜色的边界为止 |
filter() | 使用过滤器 |
flip() | 使用给定模式翻转图像 |
fontHeight() | 取得字体高度 |
fontWidth() | 取得字体宽度 |
ftbbox() | 给出一个使用 FreeType 2 字体的文本框 |
fttext() | 使用 FreeType 2 字体将文本写入图像 |
gammaCorrect() | 对 GD 图像应用 gamma 修正 |
getClip() | 取得剪切矩形 |
grabScreen() | 捕捉整个屏幕 |
grabWindow() | 捕捉指定窗口 |
interlace() | 激活或禁止隔行扫描 |
isTrueColor() | 检查图像是否为真彩色图像 |
layerEffect() | 设定 alpha 混色标志以使用绑定的 libgd 分层效果 |
line() | 画一条线段 |
loadFont() | 载入新字体 |
openPolygon() | 绘制一个开放多边形 |
paletteCopy() | 将调色板从一幅图像拷贝到另一幅 |
paletteToTrueColor() | 将基于调色板的图像转换为真颜色 |
polygon() | 画一个多边形 |
psbbox() | 给出一个使用 PostScript Type1 字体的文本方框 |
psEncodeFont() | 改变字体中的字符编码矢量 |
psExtendFont() | 扩充或精简字体 |
psFreeFont() | 释放一个 PostScript Type 1 字体所占用的内存 |
psLoadFont() | 从文件中加载一个 PostScript Type 1 字体 |
psSlantFont() | 倾斜某字体 |
psText() | 用 PostScript Type1 字体把文本字符串画在图像上 |
rectangle() | 画一个矩形 |
resolution() | 获取或设置图像的分辨率 |
rotate() | 用给定角度旋转图像 |
saveAlpha() | 设置标记以在保存 PNG 图像时保存完整的 alpha 通道信息(与单一透明色相反) |
scale() | 使用给定的新宽度和高度缩放图像 |
setBrush() | 设定画线用的画笔图像 |
setClip() | 设置剪切矩形 |
setInterpolation() | 设置插值方法 |
setPixel() | 画一个单一像素 |
setStyle() | 设定画线的风格 |
setThickness() | 设定画线的宽度 |
setTile() | 设定用于填充的贴图 |
stringHorizontal() | 水平地画一行字符串 |
stringUp() | 垂直地画一行字符串 |
sx() | 取得图像宽度 |
sy() | 取得图像高度 |
trueColorToPalette() | 将真彩色图像转换为调色板图像 |
ttfbbox() | 取得使用 TrueType 字体的文本的范围 |
ttftext() | 用 TrueType 字体向图像写入文本 |
types() | 返回当前 PHP 版本所支持的图像类型 |
iptcEmbed() | 将二进制 IPTC 数据嵌入到一幅 JPEG 图像中 |
iptcParse() | 将二进制 IPTC 块解析为单个标记 |
jpeg2Wbmp() | 将 JPEG 图像文件转换为 WBMP 图像文件 |
png2Wbmp() | 将 PNG 图像文件转换为 WBMP 图像文件 |
方法¶
__construct()¶
初始化
public function __construct (
string $filename = null,
string $from = null,
array $options = []
)
参数: |
|
---|
参数 `$options` :
$filename为null时,该参数必须指定
getSizeFromString()¶
从字符串中获取图像尺寸信息
public static function getSizeFromString (
string $imagedata,
array &$imageinfo = null
) : array
参数: |
|
---|
typeToExtension()¶
取得图像类型的文件后缀
public static function typeToExtension (
int $imagetype,
bool $include_dot = false
) : string
参数: |
|
---|
typeToMimeType()¶
返回的图像类型的 MIME 类型
public static function typeToMimeType (
int $imagetype
) : string
参数: |
|
---|
output()¶
输出图像
public function output (
string $type = null,
string $filename = null,
array $options = []
) : bool
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 如果是直接显示图像则返回null |
affine()¶
仿射变换
public function affine (
array $affine,
array $clip = null
) : resource
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
参数 `$clip` :
其中键为 "x","y","width" 和 "height"
affineMatrixConcat()¶
连接两个仿射变换矩阵
public static function affineMatrixConcat (
array $m1,
array $m2
) : array
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 失败返回false |
affineMatrixGet()¶
得到一个仿射变换矩阵
public static function affineMatrixGet (
int $type,
mixed $options = null
) : array
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 失败返回false |
alphaBlending()¶
设定图像的混色模式
public function alphaBlending (
bool $blendmode
) : bool
参数: |
|
---|
arc()¶
画椭圆弧
public function arc (
int $cx,
int $cy,
int $width,
int $height,
int $start,
int $end,
int $color
) : bool
参数: |
|
---|
参数 `$start` :
0°位于三点钟位置,以顺时针方向绘画。
参数 `$end` :
0°位于三点钟位置,以顺时针方向绘画。
char()¶
水平地画一个字符
public function char (
int $font,
int $x,
int $y,
string $c,
int $color
) : bool
参数: |
|
---|
charUp()¶
垂直地画一个字符
public function charUp (
int $font,
int $x,
int $y,
string $c,
int $color
) : bool
参数: |
|
---|
colorAllocate()¶
分配颜色
public function colorAllocate (
int $red,
int $green,
int $blue
) : int
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 成功返回配色识符,失败返回false |
colorAllocateAlpha()¶
分配带透明度颜色
public function colorAllocateAlpha (
int $red,
int $green,
int $blue,
int $alpha
) : int
参数: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 成功返回配色识符,失败返回false |
colorClosest()¶
取得与指定的颜色最接近的颜色索引
public function colorClosest (
int $red,
int $green,
int $blue
) : int
参数: |
|
---|
colorClosestAlpha()¶
取得与指定的颜色加透明度最接近的颜色索引
public function colorClosestAlpha (
int $red,
int $green,
int $blue,
int $alpha
) : int
参数: |
|
---|
colorClosestHwb()¶
取得与给定颜色最接近的色度的黑白色的索引
public function colorClosestHwb (
int $red,
int $green,
int $blue
) : int
参数: |
|
---|
colorDeallocate()¶
取消图像颜色分配
public function colorDeallocate (
int $color
) : bool
参数: |
|
---|
colorExact()¶
取得指定颜色的索引值
public function colorExact (
int $red,
int $green,
int $blue
) : int
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 如果颜色不在图像的调色板中,返回-1 |
colorExactAlpha()¶
取得指定的颜色加透明度的索引值
public function colorExactAlpha (
int $red,
int $green,
int $blue,
int $alpha
) : int
参数: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 如果颜色不在图像的调色板中,返回-1 |
colorMatch()¶
使一个图像中调色板版本的颜色与真彩色版本更能匹配
public function colorMatch (
resource $image2
) : bool
参数: |
|
---|
colorResolve()¶
取得指定颜色的索引值或有可能得到的最接近的替代值
public function colorResolve (
int $red,
int $green,
int $blue
) : int
参数: |
|
---|
colorResolveAlpha()¶
取得指定颜色 + alpha 的索引值或有可能得到的最接近的替代值
public function colorResolveAlpha (
int $red,
int $green,
int $blue,
int $alpha
) : int
参数: |
|
---|
colorSet()¶
给指定调色板索引设定颜色
public function colorSet (
int $index,
int $red,
int $green,
int $blue,
int $alpha = 0
)
参数: |
|
---|
colorsForIndex()¶
取得颜色索引的信息
public function colorsForIndex (
int $index
) : array
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 具有 red,green,blue 和 alpha 的键名的关联数组 |
colorTransparent()¶
将某个颜色定义为透明色
public function colorTransparent (
int $color = null
) : int
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 返回新透明色的标识符 |
convolution()¶
用系数 div 和 offset 申请一个 3x3 的卷积矩阵
public function convolution (
array $matrix,
float $div,
float $offset
) : bool
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回 TRUE, 或者在失败时返回 FALSE。 |
copy()¶
拷贝图像的一部分
public function copy (
mixed $src_im,
int $dst_x,
int $dst_y,
int $src_x,
int $src_y,
int $src_w,
int $src_h
) : bool
参数: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回 TRUE, 或者在失败时返回 FALSE。 |
copyMerge()¶
拷贝并合并图像的一部分
public function copyMerge (
mixed $src_im,
int $dst_x,
int $dst_y,
int $src_x,
int $src_y,
int $src_w,
int $src_h,
int $pct
) : bool
参数: |
|
---|
copyMergeGray()¶
用灰度拷贝并合并图像的一部分
public function copyMergeGray (
mixed $src_im,
int $dst_x,
int $dst_y,
int $src_x,
int $src_y,
int $src_w,
int $src_h,
int $pct
) : bool
参数: |
|
---|
copyResampled()¶
重采样拷贝部分图像并调整大小
public function copyResampled (
mixed $src_im,
int $dst_x,
int $dst_y,
int $src_x,
int $src_y,
int $dst_w,
int $dst_h,
int $src_w,
int $src_h
) : bool
参数: |
|
---|
copyResized()¶
拷贝部分图像并调整大小
public function copyResized (
mixed $src_im,
int $dst_x,
int $dst_y,
int $src_x,
int $src_y,
int $dst_w,
int $dst_h,
int $src_w,
int $src_h
) : bool
参数: |
|
---|
create()¶
新建一个基于调色板的图像
public function create (
int $width,
int $height,
bool $truecolor = true
) : resource
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
createFrom()¶
从指定资源创建
public function createFrom (
string $filename,
string $from = null,
array $options = []
) : resource
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
crop()¶
裁剪图像
public function crop (
array $rect
) : resource
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 失败时返回false |
参数 `$rect` :
[x, y, width, height]
cropAuto()¶
使用其中一种可用模式自动裁剪图像
public function cropAuto (
int $mode = -1,
float $threshold = 0.5,
int $color = -1
) : resource
参数: |
|
---|
dashedLine()¶
画一虚线
public function dashedLine (
int $x1,
int $y1,
int $x2,
int $y2,
int $color
) : bool
参数: |
|
---|
ellipse()¶
画一个椭圆
public function ellipse (
int $cx,
int $cy,
int $width,
int $height,
int $color
) : bool
参数: |
|
---|
fill()¶
区域填充,即与 x, y 点颜色相同且相邻的点都会被填充
public function fill (
int $x,
int $y,
int $color
) : bool
参数: |
|
---|
filledArc()¶
画一椭圆弧且填充
public function filledArc (
int $cx,
int $cy,
int $width,
int $height,
int $start,
int $end,
int $color,
int $style
) : bool
参数: |
---|
filledEllipse()¶
画一椭圆并填充
public function filledEllipse (
int $cx,
int $cy,
int $width,
int $height,
int $color
) : bool
参数: |
|
---|
filledPolygon()¶
画一多边形并填充
public function filledPolygon (
array $points,
int $num_points,
int $color
) : bool
参数: |
|
---|
参数 `$points` :
按顺序包含有多边形各顶点的 x 和 y 坐标的数组
filledRectangle()¶
画一矩形并填充
public function filledRectangle (
int $x1,
int $y1,
int $x2,
int $y2,
int $color
) : bool
参数: |
|
---|
fillToBorder()¶
区域填充到指定颜色的边界为止
public function fillToBorder (
int $x,
int $y,
int $border,
int $color
) : bool
参数: |
|
---|
filter()¶
使用过滤器
public function filter (
int $filtertype,
int $arg1 = null,
int $arg2 = null,
int $arg3 = null,
int $arg4 = null
) : bool
参数: |
|
---|
ftbbox()¶
给出一个使用 FreeType 2 字体的文本框
public static function ftbbox (
float $size,
float $angle,
string $fontfile,
string $text,
array $extrainfo = null
) : array
参数: |
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 数组含8个元素,失败时返回false |
fttext()¶
使用 FreeType 2 字体将文本写入图像
public function fttext (
float $size,
float $angle,
int $x,
int $y,
int $color,
string $fontfile,
string $text,
array $extrainfo = null
) : array
参数: |
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 数组含8个元素,失败时返回false |
gammaCorrect()¶
对 GD 图像应用 gamma 修正
public function gammaCorrect (
float $inputgamma,
float $outputgamma
) : bool
参数: |
|
---|
grabWindow()¶
捕捉指定窗口
public static function grabWindow (
int $window_handle,
int $client_area = 0
) : resource
参数: |
|
---|
interlace()¶
激活或禁止隔行扫描
public function interlace (
int $interlace = null
) : int
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 返回当前状态 |
layerEffect()¶
设定 alpha 混色标志以使用绑定的 libgd 分层效果
public function layerEffect (
int $effect
) : bool
参数: |
|
---|
line()¶
画一条线段
public function line (
int $x1,
int $y1,
int $x2,
int $y2,
int $color
) : bool
参数: |
|
---|
loadFont()¶
载入新字体
public static function loadFont (
string $file
) : int
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 返回字体标识 |
openPolygon()¶
绘制一个开放多边形
public function openPolygon (
array $points,
int $num_points,
int $color
) : bool
参数: |
|
---|
paletteCopy()¶
将调色板从一幅图像拷贝到另一幅
public function paletteCopy (
resource $destination
)
参数: |
|
---|
polygon()¶
画一个多边形
public function polygon (
array $points,
int $num_points,
int $color
) : bool
参数: |
|
---|
psbbox()¶
给出一个使用 PostScript Type1 字体的文本方框
public static function psbbox (
string $text,
resource $font,
int $size
) : array
参数: |
|
---|
psEncodeFont()¶
改变字体中的字符编码矢量
public static function psEncodeFont (
resource $font_index,
string $encodingfile
) : bool
参数: |
|
---|
psExtendFont()¶
扩充或精简字体
public static function psExtendFont (
resource $font_index,
float $extend
) : bool
参数: |
|
---|
psFreeFont()¶
释放一个 PostScript Type 1 字体所占用的内存
public static function psFreeFont (
resource $font_index
) : bool
参数: |
|
---|
psLoadFont()¶
从文件中加载一个 PostScript Type 1 字体
public static function psLoadFont (
string $filename
) : resource
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 失败时返回false |
psSlantFont()¶
倾斜某字体
public static function psSlantFont (
resource $font_index,
float $slant
) : bool
参数: |
|
---|
psText()¶
用 PostScript Type1 字体把文本字符串画在图像上
public function psText (
string $text,
resource $font_index,
int $size,
int $foreground,
int $background,
int $x,
int $y,
int $space = 0,
int $tightness = 0,
float $angle = 0,
int $antialias_steps = 4
) : array
参数: |
|
||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 有4个元素,失败返回false |
rectangle()¶
画一个矩形
public function rectangle (
int $x1,
int $y1,
int $x2,
int $y2,
int $color
) : bool
参数: |
|
---|
resolution()¶
获取或设置图像的分辨率
public function resolution (
int $res_x = null,
int $res_y = null
) : mixed
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 获取时返回数组[x,y],设置时返回结果 |
rotate()¶
用给定角度旋转图像
public function rotate (
float $angle,
int $bgd_color,
int $ignore_transparent = 0
) : resource
参数: |
|
---|
saveAlpha()¶
设置标记以在保存 PNG 图像时保存完整的 alpha 通道信息(与单一透明色相反)
public function saveAlpha (
bool $saveflag
) : bool
参数: |
|
---|
scale()¶
使用给定的新宽度和高度缩放图像
public function scale (
int $new_width,
int $new_height = -1,
int $mode = 3
) : resource
参数: |
|
---|
setClip()¶
设置剪切矩形
public function setClip (
int $x1,
int $y1,
int $x2,
int $y2
) : bool
参数: |
|
---|
setInterpolation()¶
设置插值方法
public function setInterpolation (
int $method = 3
) : bool
参数: |
|
---|
setPixel()¶
画一个单一像素
public function setPixel (
int $x,
int $y,
int $color
) : bool
参数: |
|
---|
setThickness()¶
设定画线的宽度
public function setThickness (
int $thickness
) : bool
参数: |
|
---|
stringHorizontal()¶
水平地画一行字符串
public function stringHorizontal (
int $font,
int $x,
int $y,
string $string,
int $color
) : bool
参数: |
|
---|
stringUp()¶
垂直地画一行字符串
public function stringUp (
int $font,
int $x,
int $y,
string $string,
int $color
) : bool
参数: |
|
---|
trueColorToPalette()¶
将真彩色图像转换为调色板图像
public function trueColorToPalette (
bool $dither,
int $ncolors
) : bool
参数: |
|
---|
ttfbbox()¶
取得使用 TrueType 字体的文本的范围
public static function ttfbbox (
float $size,
float $angle,
string $fontfile,
string $text
) : array
参数: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 8个元素,失败时返回false |
ttftext()¶
用 TrueType 字体向图像写入文本
public function ttftext (
float $size,
float $angle,
int $x,
int $y,
int $color,
string $fontfile,
string $text
) : array
参数: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
iptcEmbed()¶
将二进制 IPTC 数据嵌入到一幅 JPEG 图像中
public function iptcEmbed (
string $iptcdata,
int $spool = 0
) : mixed
参数: |
|
---|
iptcParse()¶
将二进制 IPTC 块解析为单个标记
public static function iptcParse (
string $iptcblock
) : array
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 失败时返回false |
jpeg2Wbmp()¶
将 JPEG 图像文件转换为 WBMP 图像文件
public static function jpeg2Wbmp (
$jpegname,
$wbmpname,
$dest_height,
$dest_width,
$threshold
) : bool
参数: |
|
---|
png2Wbmp()¶
将 PNG 图像文件转换为 WBMP 图像文件
public static function png2Wbmp (
$pngname,
$wbmpname,
$dest_height,
$dest_width,
$threshold
) : bool
参数: |
|
---|