blessed-contrib
blessed-contrib copied to clipboard
Allows for file streams to be passed as the file option for pictures.
Before this, options.file
had to be a String
, Buffer
, or URL
(though only a URL on the local filesystem) as it was passed directly to createReadStream
. I added in a duck typing to only create a read stream if it is not already a stream.
This feature allows for downloading files from a remote URL and passing the readable stream to the picture widget instead of actually downloading a file to some tmpfs location. The only other way I could think of doing this without downloading the file to the filesystem was to convert the fetched file to base64 and use the options.base64
option picture supports. But this is much more convenient and more efficient to boot.
@rosshadden if we're already at the picture widget thing - can I kindly ask you to take a look at this pending PR that I'd love to land? https://github.com/lirantal/picture-tuber/pull/1
it mostly minimizes no the deps that we need to fetch in blessed's dependency tree which I'd love to shorten if possible.
@lirantal It looks good to me (though I haven't tested it). I'm all for removing dependencies.
Do you plan on adding support for jpeg images, or any non-png image? Unfortunately because of that constraint I had to use another image-to-ascii converter (I went with https://github.com/1337z/display-image) instead of using this picture widget, which in turn uses picture-tuber.
I'm not planning on any updates for another format but if you could help solve the issue in the PR that would be great. Will look into this jpeg support as well later if I can.