I'm working on a server/client communication in node js. Every second, the server send an image (taking by a camera) to the client.
The message structure contains among other things:
- BufferX : the width of the image
- BufferY : the height of the image
- BufferImage : Bytes array containing pixel
The problem is: I would like to convert this buffer to an image and save it.
At first I try this:
let array = new Uint8Array(BufferImage );
fs.writeFileSync("data.png",array)
But the image isn't readable because the buffer only contains raw pixels data.
I've copy past the buffer to a python script, convert to a numpy array and reshape it. The image is correct so I'm sure that the ImageBuffer contains the correct value.
So is it possible to convert a raw pixel buffer to an image ?