No expert, but you couldn't give me better answer:) Thanks a lot! I followed your advice and it's almost there. I'm not sure it is good idea to put the PHP code here, as it is forum for imagemagick, but maybe you will see what mistake I made, or maybe it will help others with the same struggle.
First, I found out the quantum range is in my case (might be same for everybody, not sure) 65535, so I tried to simulate -contrast-stretch 0 with black point = 0, white point = quantum range and default for all channels. I experimented with only single channels, but it didn't help really. Then I created the red-white gradient and applied it with clut.
Code: Select all
$img = new Imagick('original.jpg');
$img->contrastStretchImage(0, 65535, Imagick::CHANNEL_ALL);
$clut = new Imagick();
$clut->newPseudoImage(1, 10, "gradient:red-white");
$img->clutImage($clut);
The result has smooth corners, that's good, but the color is not red. It gives me #ff2d00. It seems to be because of the contrastStretchImage() method, which is giving different result than when I run -contrast-stretch 0 in cmdline. I don't know why, I think I tried all possible combinations. When I set the black point to 30000 (keep white point same) it gives me the red, but you can see some yellowish lines at some edges. With even higher value for black point it starts to lose info, and the corners looks like in my first post. So I'm really out of ideas what more could I try.
If you see some obvious stupid error in my attempts, please correct me. If not, I really appreciate the help from both of you and I will try to fix imagemagick on the server instead.
Thank you again!