I'm currently transfering a base64
image from a client to my server with socket.io
. On the server, I want to render that base64
image into my canvas.
The code is:
function newSlide(slideImage){
socket.broadcast.emit('newSlide', slideImage);
var img = new Image;
img.src = slideImage;
ctx.drawImage(img, 0, 0);
}
With that code, on the client everything is working, I can load the base64 image into a normal canvas, but on my server in server.js
(where this code is), it's not working, I'm getting an error saying Image is not defined
at the line new Image
, when trying without the image-creation and just put in the base64
string, it says image or canvas excepted.
What's the problem with the image creation, why does it not work? And what can I do to make it working?