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
906 stars 141 forks source link

Just can't seem to get it to optimise #67

Closed DrGrimshaw closed 4 years ago

DrGrimshaw commented 5 years ago

Hi All,

I have followed the steps, installed all the correct libraries and tried in both Windows and Linux. I get no errors at all, it just doesn't optimise my images. At first I thought it wasn't finding my images but when I changed the location a non-existent image it then threw an error leaving me at a loss as to why it wouldn't optimise my images.

`require_once (DIR."/vendor/autoload.php");

$factory = new \ImageOptimizer\OptimizerFactory(array('ignore_errors' => false)); $optimizer = $factory->get(); $images = glob("images///*.{jpg,png,gif}", GLOB_BRACE); foreach ($images as $image) { $oldFileSize = filesize($image); $optimizer->optimize($image); print("Optimised: " . $image . " Saved: ".number_format((1 - $oldFileSize / filesize($image)),2) ."% \n"); }`

Can anyone suggest as to where I may be going wrong (Installed via composer, latest version).

Any help appreciated, it seems like a great library and if I can work out why I'll post my solution here.

Thanks, Dom

psliwa commented 5 years ago

Can you give me steps to reproduce? Eg. Dockerfile or Vagrantifle with environment and testing code? Maybe you have already run optimizer for all files and after that when you run second time there is no effect?