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

Feature request: accept png paths list as stdin to ease wrapper script creation #629

Open
montehurd opened this issue Jun 24, 2024 · 4 comments
Labels
T-Feature Requests for a new feature to be added

Comments

@montehurd
Copy link

montehurd commented Jun 24, 2024

If a png paths list could be passed via stdin it would be easier to optimize a subset of a collection of images ( in my use case this subset is unoptimized images ) while still leveraging oxipng's great built-in thread spawning to churn through them efficiently

@andrews05 andrews05 added the T-Feature Requests for a new feature to be added label Jun 26, 2024
@ILoveGoulash
Copy link

That's what xargs is for.

@montehurd
Copy link
Author

@ILoveGoulash Not trying to make N calls to it. Trying to let it handle thread spawning

Unless I misunderstand what you are suggesting?

@ILoveGoulash
Copy link

ILoveGoulash commented Aug 20, 2024

Yes, printf '%s\n' *.png | tr '\n' '\0' | xargs -0 oxipng is (minus corner cases related to ARG_MAX) identical to oxipng *.png.
xargs -n1 is what would make a single call per file.

But well, since oxipng does nothing with its stdin (I think?), it'd be cool to read it and add PNGs to the work queue asynchronously (something xargs can't do).

@murlakatamenka
Copy link

@montehurd just use fd:

# files will be processed 1 by 1 (i.e. not in parallel) and oxipng will be multithreaded
fd . --extension png --threads 1 --exec oxipng --preserve --opt max {}

# or with short flags
fd . -e png -j 1 -x oxipng -p -o max {}


# alternatively, run N threads for N files with single-threaded `oxipng`
fd . -e png -x oxipng -t 1 -p -o max {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Feature Requests for a new feature to be added
Projects
None yet
Development

No branches or pull requests

4 participants