ascii-image-converter icon indicating copy to clipboard operation
ascii-image-converter copied to clipboard

Feature Request: bin piping support

Open brian6932 opened this issue 3 years ago • 2 comments

It would be useful to be able quickly convert an image from stdin, like this:

curl -sSL https:/foo.bar/baz.qux | ascii-image-converter

or

curl -sSL https:/foo.bar/baz.qux | ascii-image-converter -

and can allow some more mixups like:

curl -sSL https:/foo.bar/baz.qux | magick convert - png:- | ascii-image-converter

or

curl -sSL https:/foo.bar/baz.qux | magick convert - png:- | ascii-image-converter -

I personally prefer doing it by default, but either one is fine by me 🤷

brian6932 avatar Sep 09 '22 23:09 brian6932

This is an interesting proposal, but passing binary output from stdin instead of paths/urls goes against the standard usage for this tool so I'm not sure about implementing it by default. Wouldn't a new flag like --pipe be more suitable if users intend to pass binary output?

For instance, something like this:

curl -sSL https:/foo.bar/baz.qux | ascii-image-converter --pipe

Also, it might take me a bit of time to implement this since free time for open source has been scarce as of late.. I haven't even been maintaining the project regularly 😅

TheZoraiz avatar Sep 15 '22 10:09 TheZoraiz

@TheZoraiz That's fine with me, using -, is kinda standard as an alt for the programs that don't accept input from stdin by default, but I really don't mind as long as the functionality is there

brian6932 avatar Sep 15 '22 12:09 brian6932

Just released version v1.13.0 that has bin piping support. The tool will detect piped binary input without providing any special characters. Like so:

cat myImage.png | ascii-image-converter

or

curl -sSL https:/foo.bar/baz.png | ascii-image-converter

TheZoraiz avatar Nov 14 '22 15:11 TheZoraiz

Works as intended 👍

brian6932 avatar Nov 14 '22 15:11 brian6932

I've restricted bin piping to require a hyphen as of version v1.13.1, since detection of possible piped stdin was behaving weirdly in some environments (and hence breaking some projects with ascii-image-converter as a dependency).

So usage will go like this:

cat myImage.png | ascii-image-converter -

TheZoraiz avatar Nov 23 '22 08:11 TheZoraiz