Skip to content

Image Compressor is a PHP library to compress images via the API resmush.it.

License

Notifications You must be signed in to change notification settings

Jensone/image-compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Compressor

banner

Image Compressor is a PHP library to compress images via the API resmush.it.

Installation

Install the library via Composer:

composer require jensone/image-compressor

Usage

Compress a local image

use Jensone\ImageOptimizer\ImageOptimizer;

$optimizer = new ImageOptimizer();
$optimizedImagePath = $optimizer->compressFile('/path/to/image.jpg');

Compress an image from a URL

use Jensone\ImageOptimizer\ImageOptimizer;

$optimizer = new ImageOptimizer();
$optimizedImagePath = $optimizer->compressFromUrl('https://example.com/image.jpg');

Options

You can pass an array of options to the constructor:

use Jensone\ImageOptimizer\ImageOptimizer;

$optimizer = new ImageOptimizer([
    'quality' => 92,
    'timeout' => 30
]);

The available options are:

  • quality: the quality of the compressed image (default: 92)
  • timeout: the timeout in seconds for the API call (default: 30)

License

Image Optimizer is licensed under the MIT License. See the LICENSE file for more information.

About

Image Compressor is a PHP library to compress images via the API resmush.it.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages