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

Faster method to bail on already optimized pngs? #628

Closed
montehurd opened this issue Jun 21, 2024 · 4 comments
Closed

Faster method to bail on already optimized pngs? #628

montehurd opened this issue Jun 21, 2024 · 4 comments

Comments

@montehurd
Copy link

montehurd commented Jun 21, 2024

Is there a way to make oxipng bail more quickly on images it has already optimized?

Could perhaps a flag be added which causes oxipng to write a eXIf Comment (perhaps set to "OptimizedByOxipng"?) to pngs upon being successfully optimized by it?

The flag would also cause oxipng to check for that eXIf Comment's presence in images, so it could bail more immediately upon detecting it

Maybe the flag could be called a variant of --flag-and-skip-optimized?


Context:

I'm using this once daily in my Docker container:

CMD ["oxipng", "--fix", "--recursive", "-o", "2", "."]

My dir has many subdirs with thousands of images

A fraction of these screenshot images are re-captured daily

I love the simplicity of just running oxipng recursively, especially given how effectively it utilizes available processor cores

But it would be amazing if it could devote less time to already optimized images without the user having to determine the subset of images which have yet to be optimized

Thanks for consideration and any feedback!

@andrews05
Copy link
Collaborator

Hi @montehurd, this is an interesting topic that has come up a few times. See #549, #564 and #566.
The problem is that everyone has a slightly different use case and a different idea of how it should be achieved. To quote one of my previous responses: This is a great feature for a wrapper application/script that invokes oxipng under the hood and we encourage users who would like such a feature to explore doing it this way.

Looking at the PR you linked to, it looks there already was a wrapper script that did what you're suggesting?

I'll close this as a duplicate, but feel free to add your ideas to the thread in #549.

@andrews05 andrews05 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2024
@montehurd
Copy link
Author

Thanks @andrews05

That makes sense

Quick question - is the stdin input option working?

I tried to adapt my previous wrapper script logic to pipe the list of yet-to-be optimized image paths to oxipng's stdin, with the hope oxipng could take that list and still manage spawning optimization threads across cpu cores, but I couldn't even get a single image to be optimized via stdin... wondering if maybe stdin functionality is currently broken?

@andrews05
Copy link
Collaborator

andrews05 commented Jun 23, 2024

Ah, the stdin doesn't take a path list sorry, it takes the content of a single png directly (intended for piping). You might have to use xargs or something to process a path list.
[edit] If accepting a path list as stdin would a useful feature, feel free to open a new request for that.

@montehurd
Copy link
Author

@andrews05

Done! #629

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