4

I'm having trouble colorizing (not sure if that's the correct term) a grayscale image using graphicsmagick.

Here is my starting image.

Image1

This is what I would like the result to be like. It doesn't necessarily have to be green, but I would like to be able to specify an RGB value if possible.

Image2

My result currently looks like this, don't laugh...

enter image description here

I'm currently performing multiple manipulations to the image, but colorizing it is the last step.

This is a portion of my code performing this action, irrelevant stuff has been taken out.

  gm('/tmp/'+uid+'.jpg').size(function(err, size) {
    /* croping and resizing is taking place here */
    this.write('/tmp/'+uid+'.jpg', function(err) {
      this.colorize(200, 200, 256);
      this.write("photos/processed/"+filename.replace(".jpg", ".png"), function(err) {
        if (err) console.log("error");
        else console.log("success");
        fs.unlink('/tmp/image'+uid+'.jpg');
      });
    });
  });
Jako
  • 4,731
  • 7
  • 39
  • 54
  • I don't speak *node*, but try fully desaturating the image first then applying your `colorize()` and change the `256` to `255` by the way. – Mark Setchell Feb 23 '17 at 09:06

0 Answers0