Closed jasperf closed 3 years ago
i think this was asked a while ago & sadly its not possible without using canvas which have shit load of issues on its own.
But it should there not be something possible like using Laravel Image Optimization with a config setting:
'image_optimizers' => [
Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [
'-m85', // set maximum quality to 85%
'--strip-all', // this strips out all text information such as comments and EXIF data
'--all-progressive', // this will make sure the resulting image is a progressive one
],
Spatie\ImageOptimizer\Optimizers\Pngquant::class => [
'--force', // required parameter for this package
],
Spatie\ImageOptimizer\Optimizers\Optipng::class => [
'-i0', // this will result in a non-interlaced, progressive scanned image
'-o2', // this set the optimization level to two (multiple IDAT compression trials)
'-quiet', // required parameter for this package
],
Spatie\ImageOptimizer\Optimizers\Svgo::class => [
'--disable=cleanupIDs', // disabling because it is known to cause troubles
],
Spatie\ImageOptimizer\Optimizers\Gifsicle::class => [
'-b', // required parameter for this package
'-O3', // this produces the slowest but best results
],
Spatie\ImageOptimizer\Optimizers\Cwebp::class => [
'-m 6', // for the slowest compression method in order to get the best compression.
'-pass 10', // for maximizing the amount of analysis pass.
'-mt', // multithreading for some speed improvements.
'-q 90', //quality factor that brings the least noticeable changes.
],
],
at https://github.com/spatie/laravel-medialibrary/blob/main/config/media-library.php . It uses https://github.com/spatie/image-optimizer and they also have https://github.com/spatie/laravel-image-optimizer as a Laravel package.
These packages work with libraries that do image optimization for pngs, jpgs and gifs and such
See https://spatie.be/docs/laravel-medialibrary/v9/installation-setup#optimization-tools
This however is server side and not client side. And I guess you mean to say we would need to use canvas
for client side and that has issues?
Good reads:
the spatie package is a backend optimizer, which u r more than free to pass the uploaded files to it to be processed, u can even use the mm events to pass files to spatie after upload is done.
I a lot of our images are resized on upload. This changes the dimensions properly, but the images still remain rather large in size. Any solutions for image optimization like https://spatie.be/docs/laravel-medialibrary/v6/installation-setup#optimization-tools ?