多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# The ThinkPHP5 Image Package [![Build Status](https://img.shields.io/travis/top-think/think-image.svg)](https://travis-ci.org/top-think/think-image) [![Coverage Status](https://img.shields.io/codecov/c/github/top-think/think-image.svg)](https://codecov.io/github/top-think/think-image) [![Downloads](https://img.shields.io/github/downloads/top-think/think-image/total.svg)](https://github.com/top-think/think-image/releases) [![Releases](https://img.shields.io/github/release/top-think/think-image.svg)](https://github.com/top-think/think-image/releases/latest) [![Releases Downloads](https://img.shields.io/github/downloads/top-think/think-image/latest/total.svg)](https://github.com/top-think/think-image/releases/latest) [![Packagist Status](https://img.shields.io/packagist/v/top-think/think-image.svg)](https://packagist.org/packages/topthink/think-image) [![Packagist Downloads](https://img.shields.io/packagist/dt/top-think/think-image.svg)](https://packagist.org/packages/topthink/think-image) ## 安装 > composer require topthink/think-image ## 使用 ~~~ $image = \think\Image::open('./image.jpg'); 或者 $image = \think\Image::open(request()->file('image')); $image->crop(...) ->thumb(...) ->water(...) ->text(....) ->save(..); ~~~ /** * 保存图像 * @param string $pathname 图像保存路径名称 * @param null|string $type 图像类型 * @param int $quality 图像质量 * @param bool $interlace 是否对JPEG类型图像设置隔行扫描 * @return $this */ save($pathname, $type = null, $quality = 80, $interlace = true) /** * 返回图像宽度 * @return int 图像宽度 */ width() /** * 返回图像高度 * @return int 图像高度 */ height() /** * 返回图像类型 * @return string 图像类型 */ type() /** * 返回图像MIME类型 * @return string 图像MIME类型 */ mime() /** * 返回图像尺寸数组 0 - 图像宽度,1 - 图像高度 * @return array 图像尺寸 */ size() /** * 旋转图像 * @param int $degrees 顺时针旋转的度数 * @return $this */ rotate($degrees = 90) /** * 翻转图像 * @param integer $direction 翻转轴,X或者Y * @return $this */ flip($direction = self::FLIP_X) /** * 裁剪图像 * * @param integer $w 裁剪区域宽度 * @param integer $h 裁剪区域高度 * @param integer $x 裁剪区域x坐标 * @param integer $y 裁剪区域y坐标 * @param integer $width 图像保存宽度 * @param integer $height 图像保存高度 * * @return $this */ crop($w, $h, $x = 0, $y = 0, $width = null, $height = null) * 生成缩略图 * * @param integer $width 缩略图最大宽度 * @param integer $height 缩略图最大高度 * @param int $type 缩略图裁剪类型 * * @return $this */ thumb($width, $height, $type = self::THUMB_SCALING) /** * 添加水印 * * @param string $source 水印图片路径 * @param int $locate 水印位置 * @param int $alpha 透明度 * @return $this */ water($source, $locate = self::WATER_SOUTHEAST, $alpha = 100) /** * 图像添加文字 * * @param string $text 添加的文字 * @param string $font 字体路径 * @param integer $size 字号 * @param string $color 文字颜色 * @param int $locate 文字写入位置 * @param integer $offset 文字相对当前位置的偏移量 * @param integer $angle 文字倾斜角度 * * @return $this * @throws ImageException */ text($text, $font, $size, $color = '#00000000',$locate = self::WATER_SOUTHEAST, $offset = 0, $angle = 0) /** * 切换到GIF的下一帧并保存当前帧 */ protected function gifNext()