elgervb / imagemanipulation
使用GD库的PHP图像处理库
Requires
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2024-09-12 15:38:38 UTC
README
在GitHub上Fork我:https://github.com/elgervb/imagemanipulation
使用PHP的GD库进行图像操作的库。大部分功能都通过ImageBuilder
外观提供。这样就可以实现图像过滤器链和缩略图,如下所示:
ImageBuilder::create( new \SplFileInfo('image.jpg') ) ->contrast( 20 ) // increase contrast ->colorize( '#DB3636' ) // apply a bit of red the the image ->flip( ImageFilterFlip::FLIP_VERTICALLY ) // flip image vertically ->save( new \SplFileInfo( 'image.new.png' ) ) // save the jpg image as png with filters applied ->render( 80 ); // render to browser with quality 80
安装
使用composer.json
"require" : {
"elgervb/imagemanipulation": "^1.0"
}
要求
PHP版本 >= 5.3,并包含GD库
功能
过滤器
许多图像过滤器。以下列出了所有过滤器:
- 亮度
- 着色
- 漫画
- 对比度
- 3x3卷积过滤器
- 变暗
- 躲避
- 双色
- 边缘检测
- 浮雕
- 找到边缘
- 翻转(水平、垂直、两者都翻转)
- 伽玛校正
- 高斯模糊
- 灰度
- 色调旋转
- 均值移除
- 运动模糊
- 负片
- 噪声
- 旧纸盒
- 不透明度
- 像素化
- 自定义大小和颜色的随机方块
- 替换颜色
- 反转
- 圆角
- 散布
- 选择性模糊
- 半灰度
- 棕褐色
- 快速棕褐色
- 锐化
- 平滑
- 索贝尔边缘检测
- 索贝尔边缘增强(基于卷积矩阵)
- 真彩色
- 阴影效果
叠加
使用图像作为另一个图像的叠加。可以配置叠加的不透明度、起始和结束位置以及填充选项。
反射
使用当前图像在原始图像下方创建反射
图像重复器
在画布上重复图像,直到适合。这样我们可以创建像沃霍尔一样的图像。
旋转
按度数旋转图像。当旋转的图像不等于90、180、270或360度时,您可以指定背景颜色以填充未覆盖的边缘。
缩略图
动态创建缩略图。有几种策略可以使用:
- 居中策略:从图像的中心创建缩略图。对于创建正方形缩略图特别理想,特别是从不是正方形的图像中。
- 最大策略:按最大宽度和高度调整图像大小,同时保持比例。例如:将图像(300x750)调整到最大500像素时,最终图像将是200x500像素。
- 百分比策略:以一定百分比减小图像大小。
水印
向您的图像添加水印。可能的位置有:顶部、底部、左部、右部、中心、右上角、左上角、右下角、左下角。
示例
缩略图
您可以通过多种方式创建缩略图:
居中
创建一个在图像中间居中的缩略图
最大
按最大宽度和高度调整图像大小,同时保持比例,从而将图像限制在特定大小
百分比
以一定百分比减小图像大小
方形
可用过滤器
方块
向图像添加自定义大小和颜色的随机方块
亮度
调整图像的亮度,使图像变亮或变暗
着色
将填充颜色与图像混合
漫画
将漫画滤镜应用到图像上
对比度
更改图像的对比度
###变暗调整图像的亮度,使图像变暗或变亮
###dodge Dodge an image, resulting in a darker image
###duotone Duotone filter. Enhances Red, Green or Blue or a combination
###edgedetect Uses edge detection to highlight the edges in the image
###emboss Embosses the image
###findedges Find the edges in an image without color loss
###flip Flips an image
###gammacorrection Applies gamma correction
###gaussianblur Blurs the image using the Gaussian method.
###grayscale Converts the colors to grayscale
###huerotate Rotate the hue of the image
###meanremove Uses mean removal to achieve a "sketchy" effect
###motionblur Motion blurs the image
###negative Create a negative of an image
###noise Add noise to the image
###oldcardboard Image filter to give the image an old cardboard look
###opacity Sets the opacity of an image
###pixelate Pixelate an image
###rotate Rotate an image over an angle
###scatter Scatter pixels around in a random way
###selectiveblur Image filter Selective Blur
###sepia Apply sepia to the image
###semigrayscale Applies grayscale to an image, optionally add a grayscale percentage
###sepiafast Apply sepia to the image (fast)
###sharpen Sharpens the image
###smooth Makes the image smoother.
###sobel Sobel edge detect (extremely slow...)
###sobeledge Sobel edge enhance
###truecolor Makes the image smoother.
###vignette Applies a darker mask around the edges of the image