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

Implement --terse CLI flag #419

Closed
folknor opened this issue Aug 23, 2021 · 5 comments
Closed

Implement --terse CLI flag #419

folknor opened this issue Aug 23, 2021 · 5 comments
Labels
I-Minor Issues that would be nice to have fixed, but are the lowest priority T-Feature Requests for a new feature to be added

Comments

@folknor
Copy link

folknor commented Aug 23, 2021

Hi,

Currently, oxipng supports two relevant flags; -v for verbose, which as far as I can tell is only useful for debugging of oxipng itself, and -q for quiet mode, which completely suppresses any output.

Here's an example with the default output:

$ oxipng oxipng --dir dist/www -p -s -a -D dist/www/*.png
Processing: dist/www/flagg.0f2b78c7.png
    1200x872 pixels, PNG format
    8 bits/pixel, 62 colors in palette
    IDAT size = 3358 bytes
    File size = 3840 bytes
Reducing image to 8 bits/pixel, 36 colors in palette
Trying: 2 combinations
Found better combination:
    zc = 0  zs = 0  f = 5        3067 bytes
    IDAT size = 3067 bytes (291 bytes decrease)
    file size = 3317 bytes (523 bytes = 13.62% decrease)
Output: dist/www/flagg.0f2b78c7.png

I think this is exceptionally verbose for something that is part of a build chain.

An option like --terse (or something else equivalent) to produce output like for example

$ oxipng ...
dist/www/flagg.0f2b78c7.png 13.62%

Which would be enough for me.

Or perhaps

$ oxipng ...
dist/www/flagg.0f2b78c7.png dist/www/flagg.0f2b78c7.png 3840|3317|13.62%

(src dest origsize compressed %)
Or some other way that makes it easy to parse programmatically (perhaps \t separators).

Thank you for an awesome tool, and thank you for reading my ticket!

@shssoichiro shssoichiro added I-Minor Issues that would be nice to have fixed, but are the lowest priority T-Feature Requests for a new feature to be added labels Aug 23, 2021
@TPS
Copy link

TPS commented Mar 30, 2023

How about #489 as a solution for this?

@folknor
Copy link
Author

folknor commented Mar 30, 2023

Perhaps. The pull request doesn't show an example of how the output looks with or without.

@TPS
Copy link

TPS commented Mar 31, 2023

#488 gives more info, but reading #489's diff, it looks like it'd make the info level very similar to above.

@chrispy-snps
Copy link

I would also find this useful, for the same reasons. We process hundreds of images per document, and a summary of one line per image would be perfect.

shssoichiro pushed a commit that referenced this issue Jul 11, 2023
This PR makes the oxipng binary process multiple files in parallel,
finally fulfilling #275. There seemed to be some debate about whether
oxipng _should_ do this or not but there's a couple of reasons I think
it makes sense:
1. The concern seemed mostly around the complexity of such a feature.
Not to worry, it was trivial* 🙂
2. Since then, oxipng has dropped from a max of something like 180
simultaneous compression trials down to 10, which is very much a good
thing but it does mean it's not utilising any more cores than that.

Some benchmarks on around 100 files on a machine with 8 cores:
Level | Master time | PR time
-|-|-
2 | 28.303 | 19.005
3 | 36.507 | 23.089
5 | 1:10.86 | 1:16.01

*Some additional changes were required in order to make sure sensible
output is printed to the terminal, since things won't be in order
anymore. Here's some example output from before:
```
Processing: tests/files/fully_optimized.png
    file size = 67 bytes (0 bytes = 0.00% decrease)
File already optimized
Processing: tests/files/corrupted_header.png
Invalid PNG header detected
Processing: tests/files/verbose_mode.png
    file size = 102480 bytes (12228 bytes = 10.66% decrease)
Output: tests/files/verbose_mode.png
```
And after:
```
Processing: tests/files/verbose_mode.png
Processing: tests/files/fully_optimized.png
Processing: tests/files/corrupted_header.png
tests/files/corrupted_header.png: Invalid PNG header detected
tests/files/fully_optimized.png: Could not optimize further, no change written
102480 bytes (10.66% smaller): tests/files/verbose_mode.png
```

Closes #275, #84, #169, #196 and #419.

[edit] This is the last thing I wanted to land before the next release 🥳
@andrews05
Copy link
Collaborator

Verbosity and default output is much improved in the v9 release.

Pr0methean pushed a commit to Pr0methean/oxipng that referenced this issue Dec 1, 2023
This PR makes the oxipng binary process multiple files in parallel,
finally fulfilling shssoichiro#275. There seemed to be some debate about whether
oxipng _should_ do this or not but there's a couple of reasons I think
it makes sense:
1. The concern seemed mostly around the complexity of such a feature.
Not to worry, it was trivial* 🙂
2. Since then, oxipng has dropped from a max of something like 180
simultaneous compression trials down to 10, which is very much a good
thing but it does mean it's not utilising any more cores than that.

Some benchmarks on around 100 files on a machine with 8 cores:
Level | Master time | PR time
-|-|-
2 | 28.303 | 19.005
3 | 36.507 | 23.089
5 | 1:10.86 | 1:16.01

*Some additional changes were required in order to make sure sensible
output is printed to the terminal, since things won't be in order
anymore. Here's some example output from before:
```
Processing: tests/files/fully_optimized.png
    file size = 67 bytes (0 bytes = 0.00% decrease)
File already optimized
Processing: tests/files/corrupted_header.png
Invalid PNG header detected
Processing: tests/files/verbose_mode.png
    file size = 102480 bytes (12228 bytes = 10.66% decrease)
Output: tests/files/verbose_mode.png
```
And after:
```
Processing: tests/files/verbose_mode.png
Processing: tests/files/fully_optimized.png
Processing: tests/files/corrupted_header.png
tests/files/corrupted_header.png: Invalid PNG header detected
tests/files/fully_optimized.png: Could not optimize further, no change written
102480 bytes (10.66% smaller): tests/files/verbose_mode.png
```

Closes shssoichiro#275, shssoichiro#84, shssoichiro#169, shssoichiro#196 and shssoichiro#419.

[edit] This is the last thing I wanted to land before the next release 🥳
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-Minor Issues that would be nice to have fixed, but are the lowest priority T-Feature Requests for a new feature to be added
Projects
None yet
Development

No branches or pull requests

5 participants