image-optimizer.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. use Spatie\ImageOptimizer\Optimizers\Gifsicle;
  3. use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
  4. use Spatie\ImageOptimizer\Optimizers\Optipng;
  5. use Spatie\ImageOptimizer\Optimizers\Pngquant;
  6. use Spatie\ImageOptimizer\Optimizers\Svgo;
  7. use Spatie\ImageOptimizer\Optimizers\Cwebp;
  8. return [
  9. /*
  10. * When calling `optimize` the package will automatically determine which optimizers
  11. * should run for the given image.
  12. */
  13. 'optimizers' => [
  14. Jpegoptim::class => [
  15. '-m' . (int) env('IMAGE_QUALITY', 80),
  16. '--strip-exif', // this strips out EXIF data
  17. '--all-progressive', // this will make sure the resulting image is a progressive one
  18. ],
  19. Pngquant::class => [
  20. '--force', // required parameter for this package
  21. ],
  22. Optipng::class => [
  23. '-i0', // this will result in a non-interlaced, progressive scanned image
  24. '-o7', // this set the optimization level to two (multiple IDAT compression trials)
  25. '-strip all',
  26. '-quiet', // required parameter for this package
  27. ],
  28. Svgo::class => [
  29. '--disable=cleanupIDs', // disabling because it is know to cause troubles
  30. ],
  31. Gifsicle::class => [
  32. '-b', // required parameter for this package
  33. '-O3', // this produces the slowest but best results
  34. ],
  35. Cwebp::class => [
  36. '-m 6', // for the slowest compression method in order to get the best compression.
  37. '-pass 10', // for maximizing the amount of analysis pass.
  38. '-mt', // multithreading for some speed improvements.
  39. '-q 90', // quality factor that brings the least noticeable changes.
  40. ],
  41. ],
  42. /*
  43. * The maximum time in seconds each optimizer is allowed to run separately.
  44. */
  45. 'timeout' => 59,
  46. /*
  47. * If set to `true` all output of the optimizer binaries will be appended to the default log.
  48. * You can also set this to a class that implements `Psr\Log\LoggerInterface`.
  49. */
  50. 'log_optimizer_activity' => false,
  51. ];