Documentation

Image


The image helper allows you to perform simple image manipulation.


factory(string $filename)


Creating an image object.


$image = Image::factory('original.png');

resize(integer $width, [integer $height = null, [integer $aspect_ratio = null]])


Resizes the image to the chosen size.


// Resizes the image to 50% of the original size 
$image->resize(50);
// Resizes the image to a dimension of 300x300 pixels while ignoring the aspect ratio 
$image->resize(300, 300);
// Resizes the image to a dimension of 300x300 pixels while ignoring the aspect ratio 
$image->resize(300, 300, Image::IGNORE);
// Resizes the image to the smalles possible dimension while maintaining aspect ratio 
$image->resize(300, 300, Image::AUTO);
// Resizes the image using the height to maintain aspect ratio 
$image->resize(300, 300, Image::HEIGHT);
// Resizes the image using the width to maintain aspect ratio 
$image->resize(300, 300, Image::WIDTH);

crop(integer $width, integer $height, integer $x, integer $y)


Crops the image.


$image->crop(100, 100, 10, 60);

watermark(string $file, [integer $position = null, [integer $opacity = 100]])


Adds a watermark to the image.


// Add a watermark in the top left corner
$image->watermark('watermark.png');
// Add a watermark in the top left corner
$image->watermark('watermark.png', Image::TOP_LEFT);
// Add a watermark in the top right corner
$image->watermark('watermark.png', Image::TOP_RIGHT);
// Add a watermark in the bottom right corner
$image->watermark('watermark.png', Image::BOTTOM_LEFT);
// Add a watermark in the bottom right corner
$image->watermark('watermark.png', Image::BOTTOM_RIGHT);
// Add a watermark in the center and set its opacity to 60%
$image->watermark('watermark.png', Image::CENTER, 60);

grayscale()


Convert image into grayscale.


$image->grayscale();

sepia()


Convert image into sepia.


$image->sepia();

brightness([integer $level = 0])


Convert image into brightness. Brightness level From -255(min) to 255(max)


// Set image brightness 150
$image->brightness(150);

colorize(integer $red, integer $green, integer $blue)


Convert image into colorize


$image->colorize(60, 0, 0);

contrast(integer $level)


Convert image into contrast. Contrast Level From -100(max) to 100(min) Note the direction!


// Set image contrast 60
$image->contrast(60);

rotate(integer $degrees)


Rotates the image using the given angle in degrees.


$image->rotate(90);

border([string $color = '#000', [integer $thickness = 5]])


Adds a border to the image.


$image->border('#000', 5);

save(string $file, [integer $quality = 100])


Save image.


$image->save('edited.png');