PHP Class Swoole\Image

Author: Tianfeng.Han
显示文件 Open project: matyhtf/swoole_framework Class Usage Examples

Public Properties

Property Type Description
$verifyCodeFontFile
$verifyCodeLength
$waterMarkFontFile

Public Methods

Method Description
addWaterMark ( string $groundImage, integer $waterPos, string $waterImage = "", string $waterText = "", integer $textFont = 15, string $textColor = "#FF0000", integer $minWidth = 100, integer $minHeight = 100, float $alpha = 0.9 ) : FALSE 加给图片加水印
addWaterMark2 ( string $groundImage, integer $waterPos, string $waterImage = "", string $waterText = "", integer $textFont = 5, string $textColor = "#FF0000", integer $minwidth = 100, integer $minheight = 100 ) : boolean PHP图片水印 (水印支持图片或文字) 注意:Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。 当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。 加水印后的图片的文件名和 $groundImage 一样。
cropImage ( string $image, array $params, integer $original_size, integer $crop_size ) : true/false 裁切图片,制作头像
cut ( $pic, $dst_pic, $width, $height = null, $qulitity = 100 ) : boolean 裁切图片
haveImagick ( )
readfile ( $pic ) : resource | false 读取图像
thumb_name ( $file_name, $insert = 'thumb' )
thumbnail ( $pic, $dst_pic, $max_width, null $max_height = null, integer $qulitity = 100, boolean $copy = true ) : boolean 产生图片缩略图
verifycode_chinese ( $font, $width = 180, $height = 60 ) : array 生成汉字验证码
verifycode_gd ( $img_width = 80, $img_height = 30 ) : array 生成验证码使用GD
verifycode_imagick ( integer $img_width = 80, integer $img_height = 30, boolean $addRandomLines = true, boolean $swirl = true ) : array 使用imagick扩展生成验证码图片

Method Details

addWaterMark() public static method

加给图片加水印
public static addWaterMark ( string $groundImage, integer $waterPos, string $waterImage = "", string $waterText = "", integer $textFont = 15, string $textColor = "#FF0000", integer $minWidth = 100, integer $minHeight = 100, float $alpha = 0.9 ) : FALSE
$groundImage string 要加水印地址
$waterPos integer 水印位置
$waterImage string 水印图片地址
$waterText string 文本文字
$textFont integer 文字大小
$textColor string 文字颜色
$minWidth integer 小于此值不加水印
$minHeight integer 小于此值不加水印
$alpha float 透明度
return FALSE

addWaterMark2() public static method

PHP图片水印 (水印支持图片或文字) 注意:Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。 当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。 加水印后的图片的文件名和 $groundImage 一样。
public static addWaterMark2 ( string $groundImage, integer $waterPos, string $waterImage = "", string $waterText = "", integer $textFont = 5, string $textColor = "#FF0000", integer $minwidth = 100, integer $minheight = 100 ) : boolean
$groundImage string 背景图片,即需要加水印的图片,暂只支持GIF,JPG,PNG格式;
$waterPos integer 水印位置,有10种状态,0为随机位置;1为顶端居左,2为顶端居中,3为顶端居右;4为中部居左,5为中部居中,6为中部居右;7为底端居左,8为底端居中,9为底端居右;
$waterImage string 图片水印,即作为水印的图片,暂只支持GIF,JPG,PNG格式;
$waterText string 文字水印,即把文字作为为水印,支持ASCII码,不支持中文;
$textFont integer 文字大小
$textColor string 文字颜色,值为十六进制颜色值,默认为#FF0000(红色);
$minwidth integer
$minheight integer
return boolean

cropImage() static public method

裁切图片,制作头像
static public cropImage ( string $image, array $params, integer $original_size, integer $crop_size ) : true/false
$image string 图片相对网站根目录的地址
$params array 参数,高度height=100,宽度width=116,精度qulitity=80,新图片的地址newfile,原图的真实宽度abs_width
$original_size integer 原始的尺寸
$crop_size integer 裁切的参数,高度,宽度,四点坐标
return true/false

cut() static public method

裁切图片
static public cut ( $pic, $dst_pic, $width, $height = null, $qulitity = 100 ) : boolean
$pic string 源图像
$dst_pic string 目标图像
$width int 宽度
$height int 高度
$qulitity int 质量
return boolean

haveImagick() static public method

static public haveImagick ( )

readfile() static public method

读取图像
static public readfile ( $pic ) : resource | false
$pic
return resource | false | false

thumb_name() static public method

static public thumb_name ( $file_name, $insert = 'thumb' )

thumbnail() static public method

产生图片缩略图
static public thumbnail ( $pic, $dst_pic, $max_width, null $max_height = null, integer $qulitity = 100, boolean $copy = true ) : boolean
$pic
$dst_pic
$max_width
$max_height null
$qulitity integer
$copy boolean
return boolean

verifycode_chinese() static public method

生成汉字验证码
static public verifycode_chinese ( $font, $width = 180, $height = 60 ) : array
$font
$width
$height
return array

verifycode_gd() static public method

生成验证码使用GD
static public verifycode_gd ( $img_width = 80, $img_height = 30 ) : array
$img_width
$img_height
return array

verifycode_imagick() static public method

使用imagick扩展生成验证码图片
static public verifycode_imagick ( integer $img_width = 80, integer $img_height = 30, boolean $addRandomLines = true, boolean $swirl = true ) : array
$img_width integer
$img_height integer
$addRandomLines boolean
$swirl boolean
return array

Property Details

$verifyCodeFontFile static_oe public_oe property

static public $verifyCodeFontFile

$verifyCodeLength static_oe public_oe property

static public $verifyCodeLength

$waterMarkFontFile static_oe public_oe property

static public $waterMarkFontFile