图片工具类¶
属性 | 值 |
---|---|
命名空间 | fize\image |
类名 | Image |
方法: |
---|
方法名 | 说明 |
---|---|
affine() | 仿射变换 |
crop() | 裁剪图像 |
rotate() | 用给定角度旋转图像 |
scale() | 使用给定的新宽度和高度缩放图像 |
flip() | 使用给定模式翻转图像 |
water() | 添加图片水印 |
text() | 添加文字水印 |
方法¶
affine()¶
仿射变换
public static function affine (
string $file_name,
array $affine,
array $clip = null,
string $to = null
) : bool
参数: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回true,失败时返回false |
参数 `$clip` :
其中键为 "x","y","width" 和 "height"
crop()¶
裁剪图像
public static function crop (
string $file_name,
array $rect,
string $to = null
) : bool
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回true,失败时返回false |
参数 `$rect` :
其中键为 "x","y","width" 和 "height"
rotate()¶
用给定角度旋转图像
public static function rotate (
string $file_name,
float $angle,
int $bgd_color = 0,
int $ignore_transparent = 0,
string $to = null
) : bool
参数: |
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回true,失败时返回false |
scale()¶
使用给定的新宽度和高度缩放图像
public static function scale (
string $file_name,
int $new_width,
int $new_height = -1,
int $mode = 3,
string $to = null
) : bool
参数: |
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回true,失败时返回false |
flip()¶
使用给定模式翻转图像
public static function flip (
string $file_name,
int $mode,
string $to = null
) : bool
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 成功时返回true,失败时返回false |
water()¶
添加图片水印
public static function water (
string $file_name,
string $source,
array $coord,
int $alpha = 100,
string $to = null
) : bool
参数: |
|
---|
参数 `$coord` :
支持键名[left、right、top、bottom]
text()¶
添加文字水印
public static function text (
string $file_name,
array $coord,
string $text,
string $font,
int $size,
string $color = "#00000000",
int $angle = 0,
string $to = null
) : bool
参数: |
|
---|
参数 `$coord` :
支持键名[left、right、top、bottom]