Is NodeJS Image Processing/Analysis Possible?


I'm running NodeJS on the server-side, and I'm trying to do a bit of automated image processing to determine the 'base colour' of an image.

Here are the steps of what I want to do:

  1. Take an image (on a remote server, so passed through with a URL) and get its dimensions
  2. Use dimensions to calculate the centre of the image
  3. Take a 10px x 50px (WxL) rectangle around the centre-point
  4. Get the RGB value for each of these pixels (500 per image)
  5. Output the average value of the pixels

I know such things are possible in PHP, but I'd like to use Node is possible. I've seen tutorials on using Node-imagick for basic processing (like resizing and cropping) but don't know where to start with more advanced analysis like this.


(a) Is this possible with Node?

(b) What libraries will allow me to do this?

Problem courtesy of: Jascination


A: yes

B: gm

here are some more characters to make this long enough for stackoverflow...

Solution courtesy of: Peter Lyons


node-itk may be helpful to you.

Node-ITK is a node.js wrapper, which is built on top of ITK. It was built to facilitate noe.js' use in rapid prototyping, education, and web services for Medical Image Processing.

Discussion courtesy of: summit chiu

This recipe can be found in it's original form on Stack Over Flow.