lireincore/image

Image effects, thumbnails and postprocessing

0.3.1 2019-03-24 17:12 UTC

This package is auto-updated.

Last update: 2024-03-25 05:52:15 UTC


README

Latest Stable Version Total Downloads License

About

Supports GD, Imagick and Gmagick.

Also, you can use a special extension lireincore/imgcache that adds the ability to cache thumbs.

Install

Add the "lireincore/image": "^0.3" package to your require section in the composer.json file

or

$ php composer.phar require lireincore/image

Usage

//Use basic effects
use LireinCore\Image\Manipulators\Imagine;
use LireinCore\Image\PostProcessors\OptiPng;

$image = (new Imagine())
    ->open('/path/to/image.jpg')
    ->resize(1000, 500)
    ->grayscale()
    ->blur(2)
    ->text('Hello word', 'Verdana');
    ->save('/path/to/new_image.png', ['format' => 'png', 'png_compression_level' => 7]);

$postProcessor = new OptiPng();
$postProcessor->process('/path/to/new_image.png'); //optimize image

//Also you can add extended effects
use LireinCore\Image\Manipulator;
use LireinCore\Image\Manipulators\Imagine;
use LireinCore\Image\Effects\Overlay;
use LireinCore\Image\Effects\ScaleDown;
use LireinCore\Image\Effects\Fit;
use LireinCore\Image\PostProcessors\JpegOptim;

$image = (new Imagine(Manipulator::DRIVER_GD))
    ->open('/path/to/image.jpg')
    ->apply(new Overlay('/path/to/watermark.png', 70, 'right', 'bottom', '50%', '50%'))
    ->grayscale()
    ->apply(new ScaleDown('50%', '50%', true))
    ->apply(new Fit('center', 'center', '200', '90', '#f00', 20, true))
    ->negative()
    ->save('/path/to/new_image.jpg');

$postProcessor = new JpegOptim();
$postProcessor->process('/path/to/new_image.jpg'); //optimize image

License

The MIT License (MIT). Please see License File for more information.