encode() is not working
Hi
Am on Laravel 5.5 with image type Imagick, even I have installed libwebp, WebP in my Ubuntu 16.04.
I would like to resize and change the extension of the file, so I made a even and listener to achieve it. So created a listener HasUploadedImageListener and in handle()
EventServiceProvider
ImageWasUploaded::class => [ HasUploadedImageListener::class ]
inside the handle()
$img = Image::make( $event->path() ); $img->encode( 'jpg' ); $img->resize( 720, null, function ( $constraint ) { $constraint->aspectRatio(); } ); $img->save();
But its not saving to jpg but its resizing it to 720px. Even I tried to apply the encode into the vendor file ResizeController.php but nothing is working on encode().
Kindly suggestion me how to fix this.
Same problem. Version 2.5.0. Simple: Image::make('mypngfile_wo_ext')->encode('jpg', 85)->save(); # Mime still image/png.
Same for me. Using imagick Laravel 5.8. encode() does not seem to work.
$manager = new ImageManager(['driver' => 'imagick']);
$uploadImage = $manager->make($file);
$uploadImage = $uploadImage->encode('jpg', 100);
Mime still original such as tiff.
No progress on this huh? Laravel 6.0
$img = Image::make($upload);
if($img->filesize() > 100000){
$img->encode('jpg', 5);
}
$img->save($path);
Should result in a pretty low quality jpg but saves the same as without encode.
Same issue here with Laravel 6 and 2.5.1.
Hi
Am on Laravel 5.5 with image type Imagick, even I have installed libwebp, WebP in my Ubuntu 16.04.
I would like to resize and change the extension of the file, so I made a even and listener to achieve it. So created a listener HasUploadedImageListener and in handle()
EventServiceProvider
ImageWasUploaded::class => [ HasUploadedImageListener::class ]inside the handle()
$img = Image::make( $event->path() ); $img->encode( 'jpg' ); $img->resize( 720, null, function ( $constraint ) { $constraint->aspectRatio(); } ); $img->save();But its not saving to jpg but its resizing it to 720px. Even I tried to apply the encode into the vendor file ResizeController.php but nothing is working on encode().
Kindly suggestion me how to fix this.
I think the issue is that you actually do not save the encoded but the original image.
This should work:
$img = Image::make( $event->path() );
$encodedImage = $img->encode( 'jpg' );
$encodedImage->resize( 720, null, function ( $constraint ) { $constraint->aspectRatio(); } );
$encodedImage->save();
Same issue. Version 2.5.1 with Laravel 7.24.0.
I tried bellow code and this worked.
$img = Image::make(storage_path("app/xxxxx.jpg"));
$img->save(storage_path("app/xxxxx.jpg"), 20);
The quality option of encode() is not working...
Same issue.
PHP code use this package
"name": "intervention/image", "version": "2.5.1",
still, issue? damn anyone, any luck?
works without saving:
$img = Image::make('some image');
$jpgImg = Image::make((string)$img->encode('jpg', 75));
This issue should be resolved as of version 3.