laravel-image-optimizer: jpegoptim options not running

I am using jpegoptim. Here is my config:

    'options' => [
        'ignore_errors' => false,

        'optipng_bin' => '/usr/bin/optipng',
        'optipng_options' => ['-force'],

        'gifsicle_bin'     => '/usr/bin/gifsicle',
        'gifsicle_options' => ['-b', '-O5'],

        'jpegoptim_bin'     => '/usr/bin/jpegoptim',
        'jpegoptim_options' => ['-m80'],
    ],

    'transform_handler' => [
        'png'  => 'optipng',
        'jpg'  => 'jpegoptim',
        'jpeg' => 'jpegoptim',
        'gif'  => 'gifsicle',
    ],

But when I run the code, the package compresses it using lossless compression (instead of lossy compression (-m80) like I set in the config:

$pic = public_path('landscape.jpg');
$imageOptimizer = new ImageOptimizer();
$imageOptimizer->optimizeImage($pic);

But when I run the command in the command line, it works fine:

jpegoptim -m80 landscape.jpg

I only have jpegoptim and not jpegtran.

What am I doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

@Okipa or use the old-new way like this:

$opt = app(‘Approached\LaravelImageOptimizer\ImageOptimizer’); $opt->optimizeImage($image_path, $extension);