mardi 11 décembre 2018

Laravel 5.1 Intervention Image compressing

I use Laravel 5.1 and the intervention package: http://image.intervention.io/

I try to compress my images. I would like to upload a 2.5Mb image and compress it by reducing the image size to arround 700kb by keeping the resolution and the image quality. Just reducing a large image file to a small one. The uploaded image is a .jpg file

I use the following code:

$targetFolder = public_path().'/images/';
$name=$image->getClientOriginalName();
$extension = $image->getClientOriginalExtension(); // add
$picture = sha1($name . time()) . '.' . $extension; //add

$image->move($targetFolder, $picture);
$image = \Intervention\Image\Facades\Image::make(sprintf('images/%s', $picture))->encode('jpg', 75);

But my image size is still arround 2.07Mb

The question is what method I have to use to get the desired result?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire