I have UInt8array, width, height of png image. I tried to save it like this
const screenshot = new TextDecoder('utf-8').decode(await frame.exportAsync()) // figma.com/plugin-docs/api/properties/nodes-exportasync
// passing screenshot as string over network
const uint8array = new TextEncoder('utf-8').encode(screenshot);
const data = Buffer.from(uint8array);
fs.writeFileSync(`${fileName}.png`, data, 'binary');
but this code obviously does not consider width and height.
How can I save it as png in Node.js properly?
screenshot?screenshotis new TextDecoder('utf-8').decode(await frame.exportAsync()) , where exportAsync is figma.com/plugin-docs/api/properties/nodes-exportasyncframe.exportAsync()? Also I dont think using UTF8 strings to transfer binary data is always safe.