TheZoraiz / ascii-image-converter

A cross-platform command-line tool to convert images into ascii art and print them on the console. Now supports braille art!
Apache License 2.0
2.18k stars 127 forks source link

Feature Request: bin piping support #28

Closed brian6932 closed 1 year ago

brian6932 commented 2 years ago

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 🤷

TheZoraiz commented 2 years ago

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 😅

brian6932 commented 2 years ago

@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

TheZoraiz commented 1 year ago

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
brian6932 commented 1 year ago

Works as intended 👍

TheZoraiz commented 1 year ago

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 -