Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fs = require("fs"),
- PNG = require("pngjs").PNG;
- fs.createReadStream("./anh/test.png")
- .pipe(
- new PNG({
- filterType: 4,
- inputHasAlpha: false,
- })
- )
- .on("parsed", function () {
- console.log(this.height, this.width, this.data.length)
- const matData = [];
- for (let row = 0; row < this.height; ++row) {
- const rowData = [];
- for (let col = 0; col < this.width; ++col) {
- let idx = (this.width * row + col) << 2;
- rowData.push([ this.data[idx], this.data[idx + 1], this.data[idx + 2] ])
- }
- matData.push(rowData)
- }
- console.log(matData, matData.length, matData[0].length);
- this.pack().pipe(fs.createWriteStream("out.png"));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement