Help with translating command to Imagick

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Locked
stroker
Posts: 16
Joined: 2008-04-07T11:24:55-07:00

Help with translating command to Imagick

Post by stroker »

What's the equivalent to ImageMagick cmd "convert image.jpg -fx intensity -gamma $RED,$GREEN,$BLUE out.jpg"?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with translating command to Imagick

Post by fmw42 »

see fxImage and gammaImage at http://us3.php.net/manual/en/book.imagick.php

sorry I am not an iMagick user

stroker
Posts: 16
Joined: 2008-04-07T11:24:55-07:00

Re: Help with translating command to Imagick

Post by stroker »

Ok thanks for your answer. I actually tried fxImage and gammaImage first but I was uncertain of the parameters.
It's seems that you have to call gammaImage for each color:
$im->gammaImage($RED, Imagick::CHANNEL_RED);
$im->gammaImage($GREEN, Imagick::CHANNEL_GREEN);
$im->gammaImage($BLUE, Imagick::CHANNEL_BLUE);

I've got that working but I can't get -fxImage('intensity') to work, it does nothing. What is the correct way to convert a RGB image to grayscale with the way that the eyes perceive them?
I know that our eyes are most sensitive to green and the command -fx intensity converts regarding to that. I want to use this command in php Imagick.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with translating command to Imagick

Post by fmw42 »

use the equivalent of -colorspace and see colorspaces at http://www.imagemagick.org/script/comma ... colorspace and in particular: either Rec601Luma or Rec709Luma or gray

stroker
Posts: 16
Joined: 2008-04-07T11:24:55-07:00

Re: Help with translating command to Imagick

Post by stroker »

Thanks that works. I also found out that fxImage('intensity') works as well. I used it the wrong way, the function return a new Imagick object with the changes.

Locked