Fork me on GitHub

CakeInterventionImage

CakePHP Intervention Image Plugin

View project on GitHub

Getting started

Introduction

This plugin is a Intervention Image library wrapper for CakePHP 3.

Installation

Since v3, CakePHP uses composer, the easiest way to set up the Bootstrap helpers is by either running

composer require lowg33kdev/cakephp-intervention-image:dev-master
or adding the following to your composer.json and run composer update:

"require": {
    "lowg33kdev/cakephp-intervention-image": "dev-master"
}
Do not forget to load the plugin by adding the following line into your /config/bootstrap_cli.php file:
Plugin::load('CakeInterventionImage');

If you do not use composer, simply clone the repository into your plugins/CakeInterventionImage folder by running:

git clone https://github.com/LowG33kDev/cakephp-intervention-image.git plugins/CakeInterventionImage
And then load the plugin with autoload set to true in your /config/bootstrap.php file:
Plugin::load('CakeInterventionImage' ['autoload' => true]);

Intervention tasks

Blur task

Apply a gaussian blur filter with a optional amount on the current image. Use values between 0 and 100.

Note: Performance intensive on larger amounts of blur with GD driver. Use with care.

Origin
Result

Brightness task

Changes the brightness of the current image by the given level. Use values between -100 for min. brightness 0 for no change and +100 for max. brightness.

Origin
Result

Colorize task

Change the RGB color values of the current image on the given channels red, green and blue. The input values are normalized so you have to include parameters from 100 for maximum color value 0 for no change and -100 to take out all the certain color on the image

Origin
Result

Contrast task

Changes the contrast of the current image by the given level. Use values between -100 for min. contrast 0 for no change and +100 for max. contrast.

Origin
Result

Crop task

Changes the contrast of the current image by the given level. Use values between -100 for min. contrast 0 for no change and +100 for max. contrast.

Origin
Result

Fit task

Combine cropping and resizing to format image in a smart way. The method will find the best fitting aspect ratio of your given width and height on the current image automatically, cut it out and resize it to the given dimension. You may pass an optional Closure callback as third parameter, to prevent possible upsizing and a custom position of the cutout as fourth parameter.

Flip task

Mirror the current image horizontally or vertically by specifying the mode.

Origin
Result

Gamma task

Performs a gamma correction operation on the current image.

Origin
Result

Greyscale task

Turns image into a greyscale version.

Origin
Result

Insert task

Paste a given image source over the current image with an optional position and a offset coordinate. This method can be used to apply another image as watermark because the transparency values are maintained.

Origin
Watermark
Result

Interlace task

Determine whether an image should be encoded in interlaced or standard mode by toggling interlace mode with a boolean parameter. If an JPEG image is set interlaced the image will be processed as a progressive JPEG.

Invert task

Reverses all colors of the current image.

Origin
Result

Mask task

Apply a given image source as alpha mask to the current image to change current opacity. Mask will be resized to the current image size. By default a greyscale version of the mask is converted to alpha values, but you can set mask_with_alpha to apply the actual alpha channel. Any transparency values of the current image will be maintained.

Opacity task

Set the opacity in percent of the current image ranging from 100% for opaque and 0% for full transparency.

Note: Performance intensive on larger images. Use with care.

Pixelate task

Applies a pixelation effect to the current image with a given size of pixels.

Origin
Result

Resize canvas task

Resize the boundaries of the current image to given width and/or height. An anchor can be defined to determine from what point of the image the resizing is going to happen. Set the mode to relative to add or subtract the given width or height to the actual image dimensions. You can also pass a background color for the emerging area of the image.

Resize task

Resizes current image based on given width and/or height. To constraint the resize command, pass an optional Closure callback as third parameter.

Rotate task

Rotate the current image counter-clockwise by a given angle. Optionally define a background color for the uncovered zone after the rotation.

Origin
Result

Sharpen task

Sharpen current image with an optional amount. Use values between 0 and 100.

Origin
Result