Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  71] [ 2]  / answers: 1 / hits: 21892  / 8 Years ago, tue, march 1, 2016, 12:00:00

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 ?


More From » node.js

 Answers
51

Use 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);

[#63094] Sunday, February 28, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucianom

Total Points: 601
Total Questions: 98
Total Answers: 109

Location: Kenya
Member since Fri, Dec 23, 2022
1 Year ago
lucianom questions
Tue, Feb 22, 22, 00:00, 2 Years ago
Wed, May 5, 21, 00:00, 3 Years ago
Sun, Jan 24, 21, 00:00, 3 Years ago
Sat, Aug 15, 20, 00:00, 4 Years ago
Mon, Jun 22, 20, 00:00, 4 Years ago
;