-
Notifications
You must be signed in to change notification settings - Fork 0
/
resemble.js
32 lines (27 loc) · 854 Bytes
/
resemble.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var resemblejs = require('resemblejs');
var canvas = require('canvas');
var imageType = require('image-type');
module.exports = function() {
//override FileReader
this.FileReader = function(){};
this.FileReader.prototype.readAsDataURL = function(buffer) {
this.onload({
target: {
result: 'data:image/' + imageType(buffer) + ';base64,' + buffer.toString('base64')
}
});
};
//override Image
this.Image = canvas.Image;
this.Image.prototype.setAttribute = function() {};
//override document.createElement('canvas')
this.document = {
createElement: function(tag) {
if(tag !== 'canvas') {
return false;
}
return new canvas;
}
};
return resemblejs.resemble.apply(this, arguments);
};