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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rosshadden
Copy link

@rosshadden rosshadden commented Oct 9, 2019

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.

Signed-off-by: Ross Hadden <rosshadden@gmail.com>
@lirantal
Copy link
Collaborator

lirantal commented Oct 9, 2019

@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? lirantal/picture-tuber#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.

@rosshadden
Copy link
Author

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

@lirantal
Copy link
Collaborator

lirantal commented Oct 9, 2019

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.

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.

2 participants