Add support for efficient-compression-tool
Would it be possible to add support for efficient-compression-tool? I noticed I could get extra space savings when using this on a file already optimized with image_optim.
At first look the tool is trying to improve compression, but the tools are already there, like zopfli is used by oxipng. Can you provide images for which you got better results? Maybe it is just about configuring present tools to apply maximum compression
I've only see it further optimize PNG's. You can see it with this one. Running with ect -9 -strip I see a bit of space savings, albeit not much on top of what image_optim gets. It can even further optimize that image after running oxipng --interlace 0 --quiet --strip all -o max on it.
I think the author patches several of those dependencies, which might explain the difference.
oxipng can be configured to do that by image_optim
ect is impressive IMO. Recent benchmarks here - https://github.com/oxipng/oxipng/issues/700
Doing our own benchmarks might be useful, so we could remove some tools or disable them by default. I recently disabled advpng, optipng, and pngout because they don't seem worth it (for my use case).
Might also be useful to add command line flags to facilitate benchmarking. You can sorta get timing with --verbose but we could probably output a summary without too much trouble.
@gurgeous There is script/worker_analysis for comparing all possible tool combinations and orders
I tried running it, neat! After some experimentation I ended up changing my justfile rule to disable tools that seems slow and/or ineffective for my use case (see below). Based on my results I wonder if it's even worth including some of the tools at this point.
Would you be interested in more work here? It would be fun to contribute. Example - a script included in the gem similar to script/worker/analysis, but with fewer dependencies, no chaining, no yaml file required, a nice terminal summary, etc.
My justfile rule:
image-optim:
@bundle exec image_optim \
--no-optipng --no-pngout --no-advpng \
--allow-lossy --svgo-precision=1 \
-r .
I tried running it, neat! After some experimentation I ended up changing my justfile rule to disable tools that seems slow and/or ineffective for my use case (see below). Based on my results I wonder if it's even worth including some of the tools at this point.
It always depends on input files, when understanding tools efficiency I created https://github.com/toy/image_optim_analysis with files that are used
Would you be interested in more work here? It would be fun to contribute. Example - a script included in the gem similar to script/worker/analysis, but with fewer dependencies, no chaining, no yaml file required, a nice terminal summary, etc.
Not sure I got what you mean by «no chaining». Overall you mean more of a tool for gem end users instead of developers to find what tools are efficient and which can be thrown our, or you mean adding it to main image_optim binary?
There is also this - https://css-ig.net/benchmark/png-lossless which is somewhat unwieldy but contains many sample images for benchmarking. The author is showcasing his closed-source optimizer pingo, which I think is a variant of ect.
When I said "no chaining" I was referring to the worker_analysis script, which looks like it tries to chain the optimizers together (screenshot below). Maybe we could add something like image_optim --benchmark to compare the various optimizers and output a table. Or maybe --verbose could output a table at the end, showing results similar to worker_analysis.
So currently even without verbose image_optim outputs per image percentage and space gain + total, and verbose outputs duration of every worker. And you want to also add output per worker/tool, information like avg (median, total?) ratio, time, speed, …?
Yes, I've run both with and without --verbose but I found it pretty challenging to understand the output and draw conclusions about which tools work best. This what I see with --verbose:
But I want something like this:
$ image_optim --benchmark
Running image_optim on 37 pngs. Hang on...
The actual numbers in that screenshot are made up, of course. The output is from the Table Tennis rubygem that I released. We don't need to use that, I just put it in for fun and to show what's possible.
@gurgeous Sure, it seems like it would be useful
Also probably better to further discuss if needed in a separate issue or discussions, or already in a PR, as this issue got hijacked