From 5fc960aa567aea794a199a6152933250a1338634 Mon Sep 17 00:00:00 2001 From: Cedric Wienold Date: Fri, 15 Feb 2013 16:32:07 -0800 Subject: [PATCH] Add support for Buffers to utils.loadImage If the user has preloaded image data in a Buffer, allow that user to use that data to load into a Fabric.js image. This is possible because node-canvas supports setting 'src' to a Buffer. --- src/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 9bdbad34..7d3f436d 100644 --- a/src/node.js +++ b/src/node.js @@ -77,7 +77,7 @@ callback && callback.call(context, img); }; var img = new Image(); - if (url && url.indexOf('data') === 0) { + if (url && (url instanceof Buffer || url.indexOf('data') === 0)) { img.src = img._src = url; callback && callback.call(context, img); }