elgervb/imagemanipulation
Composer 安装命令:
composer require elgervb/imagemanipulation
包简介
Library for image manipulation in PHP with GD
关键字:
README 文档
README
Fork me on GitHub: https://github.com/elgervb/imagemanipulation
Library to manipulate images using PHP's GD library. Most of the functionality is available through the ImageBuilder facade.
This way chaining of image filters and thumbnailing is possible, like:
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
Installation
With composer.json:
"require" : {
"elgervb/imagemanipulation": "^1.0"
}
Requirements
PHP version >= 5.3 with GD library
FUNCTIONALITY
Filters
Lots of image filters. All of them listed below:
- brightness
- colorize
- comic
- contrast
- convolution 3x3 filters
- darken
- dodge
- duotone
- edge detect
- emboss
- find edges
- flip (horizonal, vertical, both)
- gamma correction
- gaussian blur
- grayscale
- hue rotate
- mean remove
- motion blur
- negative
- noise
- old cardboard
- opacity
- pixelate
- random blocks with custom size and color
- replace color
- reverse
- rounded corners
- scatter
- selective blur
- semi grayscale
- sepia
- sepia fast
- sharpen
- smooth
- sobel edge detect
- sobel edge enhance (based on convolution matrix)
- true color
- vignette
Overlay
Use an image as overlay on another image. Can be configured with overlay opacity, start and end position and fill options.
Reflection
Use the current image to make a reflection below the original image
Image repeater
Repeat images on a canvas, until it fits. This way we can create Warhol like images.
Rotate
Rotate images in degrees. When rotating an image not equal to 90, 180, 270 or 360 degrees, then optionally you can specify a background color for those oncovered edges.
Thumbnails
Create thumbnails on the fly. There are several strategies to use:
- Centered strategy: create a thumb from the center of an image. Ideal for creating square thumbs from not so square images
- Max strategy: resize the image to a max width or height keeping proportions. For example: when resizing an image (300x750) on max 500 pixels, the resulting image will be 200x500 pixels
- Percentage strategy: reduce the size of an image with a certain percentage.
Watermarking
Add a watermark to your image. Possible positions are: top, bottom, left, right, center, top right, top left, bottom right, bottom left.
Examples
Thumbnails
You can create thumbnails in several ways
centered
create a thumbnail which is centered in the middle of the image
| Parameter | Default | Description |
|---|---|---|
| width | 250 | The new width of the image in pixels |
| height | 250 | The new height of the image in pixels |
max
resize the image to a max width or height keeping proportions, thus restraining the image to a certain size
| Parameter | Default | Description |
|---|---|---|
| width | 250 | The max width of the image in pixels |
| height | 250 | The max height of the image in pixels |
percentage
reduce a image with a certain percentage
| Parameter | Default | Description |
|---|---|---|
| percentage | 250 | The percentage to reduce the image with |
square
| Parameter | Default | Description |
|---|---|---|
| width | 250 | The new width of the image in pixels |
| height | 250 | The new height of the image in pixels |
Available Filters
blocks
Add random blocks to an image with custom size and color
| Parameter | Default | Description |
|---|---|---|
| number | 100 | The number of blocks |
| size | 25 | The size of the blocks in pixels |
| color | ffffff | The color of the blocks |
brightness
Adjust the brightness of the image, either lighter or darker
| Parameter | Default | Description |
|---|---|---|
| rate | 20 | The brightness level from -255 to 255, from darker to lighter |
colorize
Blends a fill color with the image
| Parameter | Default | Description |
|---|---|---|
| color | ffffff | The color to blend, either in hexadecimal or rgb(a) |
| opacity | null | The color opacity from 0 to 127 |
comic
Apply a sketchy comic filter to an image
| Parameter | Default | Description |
|---|---|---|
| opacity | 40 | The opacity from 0 to 127 |
contrast
Changes the contrast of the image
| Parameter | Default | Description |
|---|---|---|
| rate | 5 | The opacity from -100 to 100, from minimal contrast to high constrast |
###darken Adjust the brightness of the image, either darker or lighter
| Parameter | Default | Description |
|---|---|---|
| rate | 20 | The brightness level from -255 to 255, from lighter to darker |
###dodge Dodge an image, resulting in a darker image
| Parameter | Default | Description |
|---|---|---|
| rate | 75 | The dodge level between 0 and 100 |
###duotone Duotone filter. Enhances Red, Green or Blue or a combination
| Parameter | Default | Description |
|---|---|---|
| red | 0 | The amount of red to add max = 255 |
| green | 0 | The amount of green to add max = 255 |
| blue | 0 | The amount of blue to add max = 255 |
###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
| Parameter | Default | Description |
|---|---|---|
| mode | both | Direction to fip: vertical, horizontal or both |
###gammacorrection Applies gamma correction
| Parameter | Default | Description |
|---|---|---|
| input | 1.0 | Input |
| output | 1.537 | Output |
###gaussianblur Blurs the image using the Gaussian method.
###grayscale Converts the colors to grayscale
###huerotate Rotete the hue of the image
| Parameter | Default | Description |
|---|---|---|
| rotate | 90 | degrees to rotate |
###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
| Parameter | Default | Description |
|---|---|---|
| rate | 20 | The amount of noise to apply |
###oldcardboard Image filter to give the image an old cardboard look
###opacity Sets the opacity of an image
| Parameter | Default | Description |
|---|---|---|
| opacity | 80 | A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent. |
###pixelate Pixelate an image
| Parameter | Default | Description |
|---|---|---|
| rate | 20 | the blocksize in pixels |
###rotate Rotate an image over an angle
| Parameter | Default | Description |
|---|---|---|
| degrees | 90 | The degrees to rotate the image |
| color | null | The background color to apply |
###scatter Scatter pixels around in a random way
| Parameter | Default | Description |
|---|---|---|
| rate | 5 | the scatter size in pixels |
###selectiveblur Image filter Selective Blur
###sepia Apply sepia to the image
| Parameter | Default | Description |
|---|---|---|
| rate | 15 | the darken rate |
###semigrayscale Applies grayscale to an image, optionally add a grayscale percentage
| Parameter | Default | Description |
|---|---|---|
| rate | 75 | The grayscale rate |
###sepiafast Apply sepia to the image (fast)
###sharpen Sharpens the image
###smooth Makes the image smoother.
| Parameter | Default | Description |
|---|---|---|
| rate | 5 | the darken rate |
###sobel Sobel edge detect (extremely slow...)
###sobeledge Sobel edge enhance
###truecolor Makes the image smoother.
| Parameter | Default | Description |
|---|---|---|
| primary | ffffff | the primary color |
| secundary | 000000 | the secundary color |
###vignette Applies a darker mask around the edges of the image
elgervb/imagemanipulation 适用场景与选型建议
elgervb/imagemanipulation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 195 次下载、GitHub Stars 达 18, 最近一次更新时间为 2015 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「images」 「gd」 「image filters」 「manipulation」 「color utils」 「image overlays」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elgervb/imagemanipulation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elgervb/imagemanipulation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elgervb/imagemanipulation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova field for distribute your images as array of object.
Pexels API Client for www.pexels.com
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Simple filters for laravel
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 195
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 27
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-04