If you are at a loss and the composer library install isn't working for you, you can just call every one of the libraries from your install folder. It's a dirty way of doing it with composer being so convenient, but will work.
Add this to the top of your image processing file:
require "your_path/ImageOptimizer/Optimizer.php";
require "your_path/ImageOptimizer/OptimizerFactory.php";
require "your_path/ImageOptimizer/CommandOptimizer.php";
require "your_path/ImageOptimizer/Command.php";
require "your_path/ImageOptimizer/SuppressErrorOptimizer.php";
require "your_path/ImageOptimizer/ChainOptimizer.php";
require "your_path/ImageOptimizer/SmartOptimizer.php";
require "your_path/ImageOptimizer/TypeGuesser/TypeGuesser.php";
require "your_path/ImageOptimizer/TypeGuesser/SmartTypeGuesser.php";
require "your_path/ImageOptimizer/TypeGuesser/GdTypeGuesser.php";
require "your_path/ImageOptimizer/TypeGuesser/ExtensionTypeGuesser.php";
require "your_path/ImageOptimizer/Exception/Exception.php";
require "your_path/ImageOptimizer/Exception/CommandNotFound.php";
... and then call the methods as described:
$factory = new \ImageOptimizer\OptimizerFactory();
$optimizer = $factory->get();
$filepath = /* path to image */;
$optimizer->optimize($filepath);
//optimized file overwrites original one
SOURCE: https://github.com/psliwa/image-optimizer