How to write a NativeImage into a file?


I’m having trouble trying to save images from the user’s clipboard into a file. I can read an image from the clipboard as a NativeImage, but how can I export it (or .toPng():s Buffer) into a png file?

Thanks in advance!


You’ll have to use node’s fs module to do so


Thanks a lot!


Still having a small problem regarding transparency: it says in NativeImage’s documentation that PNG format supports transparency, however when I use the following code transparent areas are turned white:

fs.writeFile('tempimage.png', clipboard.readImage().toPng(), function (err) {
            if (err)
                throw err;
            console.log('It\'s saved!');

Any idea what could cause this?


Might be something to ask to @zcbenz!