How to getPixel using Node.js gm graphicsMagick wrapper -
im trying figure out how individual pixel using node.js gm graphicsmagic wrapper. overall end goal top 10 colors percentages in image. trying write few functions me result life of me can't figure out hwo pixel using gm wrapper. seems graphicsmagick has getpixels method havent had luck being able call it. appreciated.
thanks!
i wanted average color of image , solved following script:
gm(file).setformat('ppm') .resize(1, 1) .tobuffer(function (err, buffer) { var color = "rgb(" + buffer.readuint8(buffer.length - 3) + "," + buffer.readuint8(buffer.length - 2) + "," + buffer.readuint8(buffer.length - 1) + ")"; // ... });
basically, crop image , convert ppm format read pixels buffer. not optimal @ , hope there better solution, case enough.
edit: option might use custom arguments.
Comments
Post a Comment