Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Req: Print only the list of optimized images #186

Open
luboslives opened this issue Nov 29, 2020 · 2 comments
Open

Req: Print only the list of optimized images #186

luboslives opened this issue Nov 29, 2020 · 2 comments

Comments

@luboslives
Copy link

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.

@toy
Copy link
Owner

toy commented Nov 29, 2020

What do you think about filtering output using grep, like image_optim --no-progress … | grep -v '^------ '?

@luboslives
Copy link
Author

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.

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

No branches or pull requests

2 participants