Skip to content

Add method to check if optimizers are installed#83

Open
Flynsarmy wants to merge 1 commit intopsliwa:masterfrom
Flynsarmy:checkOptimizers
Open

Add method to check if optimizers are installed#83
Flynsarmy wants to merge 1 commit intopsliwa:masterfrom
Flynsarmy:checkOptimizers

Conversation

@Flynsarmy
Copy link

This PR adds a checkOptimizers() method that returns an array of all defined optimizers and whether or not they're installed. This is useful, for example, when displaying a configuration page explaining what needs to be installed for certain image types to compress correctly.

I had to make some private fields public for this to work.

Example usage:

$factory = new \ImageOptimizer\OptimizerFactory();
print_r($factory->checkOptimizers());
Array
(
    [/usr/local/bin/optipng] => true
    [/usr/local/bin/pngquant] => true
    [/usr/local/bin/pngcrush] => true
    [pngout] => false
    [/usr/local/bin/advpng] => true
    [/usr/local/bin/gifsicle] => true
    [/usr/local/bin/jpegoptim] => true
    [/usr/local/bin/jpegtran] => true
    [/usr/local/bin/svgo] => true
)

@Flynsarmy Flynsarmy changed the title Add function to check if optimizers are installed Add method to check if optimizers are installed Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant