Skip to content
Compress your image without losing quality
Branch: v0.0.6
Clone or download
Latest commit 16d1058 May 24, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample Fix sample example Aug 3, 2018
src Add namespace Aug 3, 2018
.gitignore Publish Project Nov 12, 2016
LICENSE Initial commit Nov 12, 2016 Update May 14, 2019
autoload.php Publish Project Nov 12, 2016
composer.json Update projet Aug 3, 2018

Latest Stable Version Total Downloads Latest Unstable Version License

Compress Image

Compress your image without losing quality

How to use

Clone this project inside the project that you want to use

composer require eihror/compress-image

Create variables to receive the elements

$file = 'koala.jpg'; //file that you wanna compress
$new_name_image = 'koala_mini'; //name of new file compressed
$quality = 60; // Value that I chose
$pngQuality = 9; // Exclusive for PNG files
$destination = 'content'; //This destination must be exist on your project

The quality works only for JPG�s images. But if you want to change the file to PNG�s, you have to change manually via code. GIF doesn't affect the quality

Default quality for PNG: 9 ( 0 - no compression, 9 - max compression ) Create a new instance of a class

$image_compress = new Eihror\Compress\Compress($file, $new_name_image, $quality, $pngQuality, $destination);

And make the compression calling the function compress_image


This function will return only the name of new image compressed with your respective extension

That´s it! Feel free to use and making the code better if you find something different or wrong

You can’t perform that action at this time.