psliwa / image-optimizer

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
MIT License
910 stars 141 forks source link

Uncaught exception 'ImageOptimizer\Exception\CommandNotFound' with message 'Command "jpegoptim" not found.' in /home/mitradecom/vendor/ps/image-optimizer/src/ImageOptimizer/Command.php:42 Stack trace: #0 /home/mitradecom/vendor/ps/image-optimizer/src/ImageOptimizer/CommandOptimizer.php(29): ImageOptimizer\Command->execute(Array) #1 /home/mitradecom/public_html/share42/test.php(20): ImageOptimizer\CommandOptimizer->optimize('/home/mitradeco...') #2 {main} thrown in /home/mitradecom/vendor/ps/image-optimizer/src/ImageOptimizer/Command.php on line 42 #56

Closed mitrades closed 5 years ago

mitrades commented 6 years ago

Hi I receive this messsage

Fatal Error Uncaught exception 'ImageOptimizer\Exception\CommandNotFound' with message 'Command "jpegoptim" not found.' in /home/mitradecom/vendor/ps/image-optimizer/src/ImageOptimizer/Command.php:42 Stack trace: #0 /home/mitradecom/vendor/ps/image-optimizer/src/ImageOptimizer/CommandOptimizer.php(29): ImageOptimizer\Command->execute(Array)

1 /home/mitradecom/public_html/share42/test.php(20): ImageOptimizer\CommandOptimizer->optimize('/home/mitradeco...')

2 {main} thrown in /home/mitradecom/vendor/ps/image-optimizer/src/ImageOptimizer/Command.php on line 42

cusster commented 6 years ago

@mitrades I believe it should be resolved automagically, given that jpegoptim library is already installed. But you can explicitly define the path to the jpegoptim executable:

$optimizer = new ImageOptimizer\OptimizerFactory([
  'ignore_errors'  => false,
  'jpegoptim_bin' => '/path/to/jpegoptim'
]);

Make sure that the user/group of the PHP process has the permission to execute the command.

mitrades commented 5 years ago

Thanks