This has nothing to do with client side code. This is pure NodeJs I have this code for node which accepts base64 Image and resize the image to the specified h & w below.
NOTE: imgData is the base64 image
var height = 148,
width = 274,
canvas = new Canvas(height, width),
ctx = canvas.getContext('2d');
canvas.width = width;
canvas.height = height;
ctx.drawImage(imgData, 0, 0, width, height);
return canvas.toDataURL();
I see no problem with this but I am having an error on ctx.drawImage(imgData, 0, 0, width, height);
This is the error details:
/vagrant/app/server/helpers/image_helper.js:41
ctx.drawImage(imgData, 0, 0, width, height);
^
TypeError: Image or Canvas expected
at TypeError (native)
at Object.module.exports.generateThumbnailImage (/vagrant/app/server/helpers/image_helper.js:41:13)
at Object.<anonymous> (/vagrant/app/server/service/blobstorage.js:35:25)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Any help would be very much appreciated.