You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var Canvas = require('canvas')
var Image = Canvas.Image;
var fs = require('fs');
fs.readFile(__dirname + '/img/image.png', function(err, data){
if (err) throw err;
var img = new Image();
img.onload = function(){
var canvas = new Canvas(img.width, img.height);
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, img.width, img.height);
var imageData = ctx.getImageData();
}
img.src = data;
});
// LOG BELOW
var imageData = ctx.getImageData();
^
Error: IndexSizeError: The source width is 0.
at Error (native)
at img.onload (/MyProject/test.js:12:25)
at Image.src (/MyProject/node_modules/canvas/lib/image.js:30:17)
at /MyProject/index.js:40:11
at FSReqWrap.readFileAfterClose as oncomplete
The text was updated successfully, but these errors were encountered:
var Canvas = require('canvas')
var Image = Canvas.Image;
var fs = require('fs');
fs.readFile(__dirname + '/img/image.png', function(err, data){
if (err) throw err;
var img = new Image();
img.onload = function(){
var canvas = new Canvas(img.width, img.height);
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, img.width, img.height);
var imageData = ctx.getImageData();
}
img.src = data;
});
// LOG BELOW
var imageData = ctx.getImageData();
^
Error: IndexSizeError: The source width is 0.
at Error (native)
at img.onload (/MyProject/test.js:12:25)
at Image.src (/MyProject/node_modules/canvas/lib/image.js:30:17)
at /MyProject/index.js:40:11
at FSReqWrap.readFileAfterClose as oncomplete
The text was updated successfully, but these errors were encountered: