Change Image Color with MagickWand

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply

Change Image Color with MagickWand

Post by Floezen » 2008-10-31T17:20:54-07:00


I want to colorize images but haven't found the right method for it.

In Photoshop I would colorize it with a color angle of 33° and a saturation of 17.

What I thought would be easiest with MagickWand is to use the MagickMapImage() function. So I took a color gradient with all used colors.
The Problem is, that some gradients in the MagickMapImage converted picture are not smooth enough. In the attached examples you can see the that the sky above the building looks like a high compressed jpeg or gif image.

The original:

The MagickMapImage converted image

The Photoshop converted image:

Is there a way to get it look like the photoshop converted image?
Is there maybe a better function?

Kind regards

Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Change Image Color with MagickWand

Post by el_supremo » 2008-10-31T18:15:04-07:00

The -modulate operator might help you but I can't figure out which values will give you the same result.
See: ... p#modulate



Re: Change Image Color with MagickWand

Post by Floezen » 2008-11-02T06:40:41-07:00

Yes, maybe it would help turning the image to an b&w image first and than colorizing it.
Unfortunately I don't know how to describe the color I want to ImageMagick/MagickWand

The color spectrum of this image should be a
Hue 33°
Sat. 17%
and brightness is variable

What function could I use an how would I write this?

MagickSetImageColormapColor() sounds good, but I don't know how to write it.
MagickSetImageColormapColor( $resource, float index, PixelWand mapcolor_pxl_wnd )
If this function is appropriate for what I want to do, how would the float index and PixelWand mapcolor_pxl_wnd have to look like?

I think MagickColorizeImage() is inappropriate, because white will not be obtained.


Post Reply