diff --git a/lib/image.coffee b/lib/image.coffee index b1d420e..e46e8bb 100644 --- a/lib/image.coffee +++ b/lib/image.coffee @@ -13,8 +13,13 @@ class PDFImage if Buffer.isBuffer(src) data = src else - data = fs.readFileSync src - return unless data + if src[0..4] is 'data:' and src.indexOf(';base64,') > -1 + base64String = src.split(';base64,')[1] + data = new Buffer(base64String, 'base64') + + else + data = fs.readFileSync src + return unless data if data[0] is 0xff and data[1] is 0xd8 return new JPEG(data, label)