From cba44c76cc7ceeda52e9d2c7d2b906e3bf2ee1dc Mon Sep 17 00:00:00 2001 From: Ross Hadden Date: Wed, 9 Oct 2019 16:09:31 -0400 Subject: [PATCH] Allows for file streams to be passed as the file option for pictures. Signed-off-by: Ross Hadden --- lib/widget/picture.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/widget/picture.js b/lib/widget/picture.js index c954212..945010a 100644 --- a/lib/widget/picture.js +++ b/lib/widget/picture.js @@ -29,8 +29,10 @@ Picture.prototype.setImage = function(options) { var tube = pictureTube( { cols: options.cols } ); - if (options.file) fs.createReadStream(options.file).pipe(tube); - else if (options.base64) { + if (options.file) { + if (typeof options.file.pipe !== 'function') options.file = fs.createReadStream(options.file); + options.file.pipe(tube); + } else if (options.base64) { var memStream = new MemoryStream(); memStream.pipe(tube); var buf = new Buffer(options.base64, 'base64');