I have created some image data which I've obtained from pixels. Anyway, now I would like to write a file using save-pixels, but the docs only give
var savePixels = require("save-pixels")
...
savePixels(pixels, "png").pipe(process.stdout)
How to rewrite this such that it writes it to a file with a specific name ?
I have created some image data which I've obtained from pixels. Anyway, now I would like to write a file using save-pixels, but the docs only give
var savePixels = require("save-pixels")
...
savePixels(pixels, "png").pipe(process.stdout)
How to rewrite this such that it writes it to a file with a specific name ?
Share Improve this question asked Mar 1, 2016 at 17:11 Jeanluca ScaljeriJeanluca Scaljeri 29.1k66 gold badges231 silver badges379 bronze badges1 Answer
Reset to default 40Use the file system module included with node. Something like this:
var fs = require("fs");
var savePixels = require("save-pixels");
var myFile = fs.createWriteStream("myOutput.txt");
...
savePixels(pixels, "png").pipe(myFile);