Guest User

Untitled

a guest
Sep 20th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. var fs = require('fs'),
  2. PNG = require('pngjs').PNG;
  3.  
  4. fs.createReadStream('s.png')
  5. .pipe(new PNG({
  6. filterType: 4
  7. }))
  8. .on('parsed', function() {
  9.  
  10. for (var y = 0; y < this.height; y++) {
  11. for (var x = 0; x < this.width; x++) {
  12. var idx = (this.width * y + x) << 2;
  13. if(this.data[idx] != 0 && this.data[idx] != this.data[idx+1]) {
  14. console.log(y, x)
  15. }
  16. }
  17. }
  18.  
  19. this.pack().pipe(fs.createWriteStream('out.png'));
  20. });
Add Comment
Please, Sign In to add comment