elgervb/imagemanipulation

使用GD库的PHP图像处理库

1.2.0 2015-09-02 12:32 UTC

This package is not auto-updated.

Last update: 2024-09-12 15:38:38 UTC


README

Build Status Latest Stable Version
在GitHub上Fork我:https://github.com/elgervb/imagemanipulation Bitdeli Badge

使用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像素。
  • 百分比策略:以一定百分比减小图像大小。

水印

向您的图像添加水印。可能的位置有:顶部、底部、左部、右部、中心、右上角、左上角、右下角、左下角。

示例

缩略图

您可以通过多种方式创建缩略图:

居中

创建一个在图像中间居中的缩略图

示例
Centered Thumb Centered Thumb Centered Thumb

最大

按最大宽度和高度调整图像大小,同时保持比例,从而将图像限制在特定大小

示例
Max Thumb Max Thumb Max Thumb

百分比

以一定百分比减小图像大小

示例
Max Thumb Max Thumb Max Thumb

方形

示例
Centered Thumb Centered Thumb Centered Thumb

可用过滤器

方块

向图像添加自定义大小和颜色的随机方块

示例
Blocks Filter Blocks Filter Blocks Filter

亮度

调整图像的亮度,使图像变亮或变暗

示例
Brightness Filter Brightness Filter Darker Brightness Filter Lighter

着色

将填充颜色与图像混合

示例
Colorize Filter Colorize Filter red Colorize Filter green

漫画

将漫画滤镜应用到图像上

示例
Comic Filter Comic Filter Comic Filter

对比度

更改图像的对比度

示例
Contrast Filter Contrast Filter Contrast Filter

###变暗调整图像的亮度,使图像变暗或变亮

示例
Darken Filter Darken Filter Lighter Darken Filter Darker

###dodge Dodge an image, resulting in a darker image

示例
Dodge Filter Dodge Filter Lighter Dodge Filter Darker

###duotone Duotone filter. Enhances Red, Green or Blue or a combination

示例
Dodge Filter Dodge Filter Lighter Dodge Filter Darker

###edgedetect Uses edge detection to highlight the edges in the image

示例
Edge detect Filter

###emboss Embosses the image

示例
Edge detect Filter

###findedges Find the edges in an image without color loss

示例
Edge detect Filter

###flip Flips an image

示例
Flip Filter Flip Filter Vertical Flip Filter Horizontal

###gammacorrection Applies gamma correction

示例
Gamma Correction Filter Gamma Correction Vertical FlipGamma Correction Horizontal

###gaussianblur Blurs the image using the Gaussian method.

示例
Gaussian Blur Filter

###grayscale Converts the colors to grayscale

示例
Gaussian Blur Filter

###huerotate Rotate the hue of the image

示例
Hue Rotate Filter Hue Rotate Filter Hue Rotate Filter

###meanremove Uses mean removal to achieve a "sketchy" effect

示例
Gaussian Blur Filter

###motionblur Motion blurs the image

示例
Gaussian Blur Filter

###negative Create a negative of an image

示例
Gaussian Blur Filter

###noise Add noise to the image

示例
Noise Filter Noise Filter Noise Filter

###oldcardboard Image filter to give the image an old cardboard look

示例
Gaussian Blur Filter

###opacity Sets the opacity of an image

示例
Opacity Filter Opacity Filter Opacity Filter

###pixelate Pixelate an image

示例
Pixelate Filter Pixelate Filter Pixelate Filter

###rotate Rotate an image over an angle

示例
Rotate Filter Rotate Filter Rotate Filter

###scatter Scatter pixels around in a random way

示例
Scatter Filter Scatter Filter Scatter Filter

###selectiveblur Image filter Selective Blur

示例
Selective blur Filter

###sepia Apply sepia to the image

示例
Sepia Filter Sepia Filter Sepia Filter

###semigrayscale Applies grayscale to an image, optionally add a grayscale percentage

示例
Sepia Filter Sepia Filter Sepia Filter

###sepiafast Apply sepia to the image (fast)

示例
Sepia fast Filter Sepia fast Filter Sepia fast Filter

###sharpen Sharpens the image

示例
Sepia fast Filter

###smooth Makes the image smoother.

示例
Smooth Filter Smooth Filter Smooth Filter

###sobel Sobel edge detect (extremely slow...)

示例
Sobel Edge Detect Filter

###sobeledge Sobel edge enhance

示例
Sobel Edge Detect Filter

###truecolor Makes the image smoother.

示例
Smooth Filter Smooth Filter Smooth Filter

###vignette Applies a darker mask around the edges of the image

示例
Smooth Filter