Open tslater opened 7 years ago
In this example, the .end(pixels)
writes to the file (pipe
returns the destination stream, not the source stream). So try something like this:
var enc = new PNGEncoder(10, 10, { colorSpace: 'indexed', palette: palette })
.pipe(fs.createWriteStream('out.png'));
enc.end(pixels)
I'm trying that, but have the same result:
var PNGEncoder = require('png-stream/encoder');
var fs = require('fs');
var palette = new Buffer([ 256 ]);
var pixels = new Buffer(10 * 10);
pixels.fill(1);
var enc = new PNGEncoder(10, 10, { colorSpace: 'indexed', palette: palette })
.pipe(fs.createWriteStream('out.png'));
enc.end(pixels);
Thanks for your help by the way!
I tried encoding a basic png, using the test file as an example
My os says that the file is corrupted though. Where am I going wrong?