Created
July 8, 2015 15:59
-
-
Save klucar/690b047c5b4c8be03924 to your computer and use it in GitHub Desktop.
NodeJS script to extract the color palette of a PNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: node png_colors.js | sort | uniq | |
// | |
// ignores alpha | |
var PNG = require('png-js'); | |
var myimage = PNG.load('my_image.png'); | |
myimage.decodePixels(function (pixels) { | |
for( var ii = 0; ii < pixels.length; ii = ii + 4){ | |
console.log( pixels.readUInt32BE(ii).toString(16).substring(0,6)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment