I wanted to get the average color of the image, and I solved it with the 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, you can crop the image and convert it to ppm format to read pixels from the buffer. Not entirely optimal, and I really hope that there is a better solution, but for my case it was good enough.
Edit: Another option would be to use Custom Arguments .
source share