Open rainer-maucher opened 10 years ago
I've had the same issue previously and it turned out to be caused by using a newer version of node-canvas. Explicitly setting the correct versions in my package.json solved the issue for me:
"kittydar": "0.1.6",
"canvas": "1.0.1"
Hi, ok i had adifferent canvas version, but unfortunately this didn't made the trick for me, could you maybe post your whole package.json ? Maybe there are more differences... Just to make sure, even your node.js version would be great :)
Mhm, sorry my mistake i the kittydar had the old canvas installation inside itsself... fixing this to the version you gave me solved the problem, it works now.
I am using Pi too, with the latest Raspbian.
I had problem with node-canvas 1.0.1, so manually installed the latest, which gives me the same error. However, as stated in https://github.com/Automattic/node-canvas/issues/487, I just point to the same node-canvas as a temporary fix, and everything is fine.
var kittydar = require('kittydar');
var Canvas = require('kittydar/node_modules/canvas');
Hi by executing: node test.js on a raspberry Pi with kittydar 1.6
where test.js contains the following JS:
var http = require('http'), fs = require('fs'), Canvas = require('canvas'); kittyDar = require('kittydar');
fs.readFile('/var/www/kittenpush/web/images/userData/kittenimage.jpg', function(err, squid){ if (err) throw err;
img = new Canvas.Image; img.src = squid;
var canvas = new Canvas(img.width, img.height); var ctxxxx = canvas.getContext('2d'); ctxxxx.drawImage(img, 0, 0, img.width, img.height,0,0,img.width,img.height);
console.log(canvas); var cats = kittyDar.detectCats(canvas); console.log("there are", cats.length, "cats in this photo"); });
I'm ending up with an error insite the kittydar:
[Canvas 1600x1200]
/home/pi/node_modules/kittydar/kittydar.js:151 ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, ^ TypeError: Image or Canvas expected at resizeCanvas (/home/pi/node_modules/kittydar/kittydar.js:151:7) at Object.kittydar.scaleCanvas (/home/pi/node_modules/kittydar/kittydar.js:96:14) at Object.kittydar.getAllSizes (/home/pi/node_modules/kittydar/kittydar.js:81:28) at Object.kittydar.detectCats (/home/pi/node_modules/kittydar/kittydar.js:56:24) at /home/pi/test.js:19:23 at fs.js:266:14 at Object.oncomplete (fs.js:107:15)
Im not sure maybe im just missing something on creating my canvas, but it seems like the kittydar package looses the canvas during execution?
Has anyone else this issue? Would be glad if someone could help.