image_optim
image_optim copied to clipboard
Req: Print only the list of optimized images
Hi again @toy.
I have a service which runs a script which runs image_optim
over an entire WordPress uploads directory, so I also keep a cache of previously-optimized images using --cache-dir
.
Unfortunately by default, image_optim
prints out the complete list of files it checked in the directory. In this case, that is thousands of image files dating back several years. So at a certain point the results stop printing to my systemd service log.
Example, I upload img2
to the WordPress media uploads dir. I would get thousands of skipped files and the one optimized file:
...
------ /home/<host>/html/wp-content/uploads/2020/11/img1-240x240.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img1-360x360.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img1-720x720.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img1-960x960.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img1.jpg
12.17% 2.9K /home/<host>/html/wp-content/uploads/2020/11/img2-240x240.jpg
10.56% 2.7K /home/<host>/html/wp-content/uploads/2020/11/img2-360x203.jpg
7.35% 3.1K /home/<host>/html/wp-content/uploads/2020/11/img2-360x360.jpg
4.31% 3.0K /home/<host>/html/wp-content/uploads/2020/11/img2-720x405.jpg
2.80% 3.3K /home/<host>/html/wp-content/uploads/2020/11/img2-720x720.jpg
2.30% 2.4K /home/<host>/html/wp-content/uploads/2020/11/img2-960x540.jpg
4.70% 20.9K /home/<host>/html/wp-content/uploads/2020/11/img2.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img3-240x240.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img3-360x360.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img3-720x720.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img3-960x960.jpg
------ /home/<host>/html/wp-content/uploads/2020/11/img3.jpg
...
With the service log, it just stops printing around the year 2016. I'm using --no-progress
and that saves a few lines, but this should probably have its own flag.
So, I would really benefit from only seeing the savings of the newly optimized images. You can decide if you want to make this the default behaviour and maybe add a new flag like --show-skipped-files
or --print-cached-files
, or you could keep the default behaviour and add a flag like --quite-mode
or maybe create levels of verbosity?.... -v 1
, -v 2
. That would clash with the old -v
flag though.
What do you think about filtering output using grep, like image_optim --no-progress … | grep -v '^------ '
?
What do you think about filtering output using grep, like
image_optim --no-progress … | grep -v '^------ '
?
Thanks, that will do the trick! You can leave this idea open if you feel like it might be worth implementing into image_optim.