blessed-contrib icon indicating copy to clipboard operation
blessed-contrib copied to clipboard

Allows for file streams to be passed as the file option for pictures.

Open rosshadden opened this issue 5 years ago • 3 comments

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 avatar Oct 09 '19 20:10 rosshadden

@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 avatar Oct 09 '19 20:10 lirantal

@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.

rosshadden avatar Oct 09 '19 21:10 rosshadden

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.

lirantal avatar Oct 09 '19 21:10 lirantal