DrawImage in canvas with Node.js -
I'm actually trying to get the data of each images but to do this, Need to pull in
The node interpreter says that my image is not fully loaded, but I do not know why.
ctx.drawImage (IMG, 0, 0, IMGWith / 4, IMG. / 4High); ^ Error: The given image has not been able to complete the loading on the function. Check img Load image (c: \ *** \ SearchWong image. JS: 44: 6) in C: \ *** \ Searchwang image. JS: 26:25 at FSGS: 271: 14 Object. Complement (fs.js: 107: 15)
Does anyone know what is wrong with my program because I searched but I could not find an address, here is my code:
var fs = is required ('FS'); Var path = requirement ('path'); Var canvas = is required ('canvas'), ImageCanvas = Canvas.Image; Var dir = 'images /'; Function checkIMG () {} module Exports = checkImg; Var img = new canvas Image; CheckIMG.BrowseFolder = function {fs.readdir (dir, function (err, files) {If (mistake) is a mistake, then files.forEach (function {fs.readFile (dir + file, function (err, Data)) {throw (if); var bool = CheckIMG.LoadImage (data); if (bool === incorrect) console.log ("delete file") //fs.unlinkSync(file);})} };}); } CheckIMG.LoadImage = function (data) {img.src = data; Var Canvas = New Canvas (IMG Width, IMG. High); Var ctx = canvas.getContext ('2d'); Ctx.drawImage (img, 0, 0, img.width / 4, img.height / 4); Var ImageData = ctx.getImageData (70, 50, IMG Wideth, IMG Highlight); Console.log (imageData)}
Comments
Post a Comment