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

✨ New Feature: Add for support for STDIN/STDOUT workflow #11

Open
wants to merge 3 commits into
base: frostoven
Choose a base branch
from

Conversation

markstos
Copy link
Contributor

@markstos markstos commented Dec 3, 2024

Fixes #10.

QA Log

  • Tested both the STDIN and STDOUT features manually.

@markstos
Copy link
Contributor Author

markstos commented Dec 7, 2024

This has a bug. It is reading from STDIN immediately, so if there's a pause in the pipeline, for example for annotate an image in swappy, it fails. Here's an example to that fails right now:

grimshot save area - | swappy -f - --output-file - | squoosh-filter | wl-copy -t image/jpeg

What's squoosh-filter? It wraps enabling both STDIN and STDOUT support as well some default filter options.

#!/bin/sh
# Expects image on STDIN, prints optimized JPEG to stdout
squoosh-cli --stdout --mozjpeg '{"quality":75,"baseline":false,"arithmetic":false,"progressive":true,"optimize_coding":true,"smoothing":0,"color_space":3,"quant_table":3,"trellis_multipass":false,"trellis_opt_zero":false,"trellis_opt_table":false,"trellis_loops":1,"auto_subsample":true,"chroma_subsample":2,"separate_chroma_quality":false,"chroma_quality":75}' -

I think the fix is to update the code to wait for STDIN to be closed before reading the file. Looking.

@aggregate1166877
Copy link
Contributor

I think the fix is to update the code to wait for STDIN to be closed before reading the file. Looking.

Thank you for the effort. Will wait to hear from you before testing / merging.

I don't know if this helps, but my understanding is that Node handles pipes in odd ways - there was a discussion on the topic here:

The bottom two comments are probably the most relevant.

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

Successfully merging this pull request may close these issues.

feature request: Support STDIN / STDOUT workflow.
2 participants