ytubes/image-compressor

There is no license information available for the latest version (1.0.0) of this package.

Image compress

1.0.0 2017-09-07 10:12 UTC

This package is not auto-updated.

Last update: 2024-11-23 03:17:26 UTC


README

Wrapper to any image compression engine

Install via composer

"ytubes/image-compressor": "^1.0.0"

Example usage

$testImage = new \SplFileInfo('/some_dir/test.jpg');
$newFilepath = '/destination/dir/test3.jpg';

$driver = 'guetzli'; // or
// $driver = \ImageCompressor\Driver\Guetzli::class; // or
// $driver = new \ImageCompressor\Driver\Guetzli('/path/to/guetzli');

$compressor = new \ImageCompressor\ImageCompressor($driver);
$compressor
    ->setOriginalFile($testImage)
    ->setDestination($newFilepath)
    ->setQuality(90)
    ->compress();

Or overwrite self:

$compressor = (new \ImageCompressor\ImageCompressor($driver));
$compressor
    ->setOriginalFile($testImage)
    ->compress();