The image helper allows you to perform simple image manipulation.
Creating an image object.
$image = Image::factory('original.png');
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);
Crops the image.
$image->crop(100, 100, 10, 60);
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);
Convert image into grayscale.
$image->grayscale();
Convert image into sepia.
$image->sepia();
Convert image into brightness. Brightness level From -255(min) to 255(max)
// Set image brightness 150 $image->brightness(150);
Convert image into colorize
$image->colorize(60, 0, 0);
Convert image into contrast. Contrast Level From -100(max) to 100(min) Note the direction!
// Set image contrast 60 $image->contrast(60);
Rotates the image using the given angle in degrees.
$image->rotate(90);
Adds a border to the image.
$image->border('#000', 5);
Save image.
$image->save('edited.png');