Adjustments > black and white > preset feature

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.
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Adjustments > black and white > preset feature

Post by mjamal »

Hello Team,

Can anyone provide the details if the below photoshop options are available in PHP iMagick library?

1. image > adjustments > black and white > preset = infrared
2. image > adjustments > black and white > preset = maximum black

Ie I need to implement the above two options for the the image in PHP application.

Let me know if this is possible via iMagick or image magick.

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

Re: Adjustments > black and white > preset feature

Post by fmw42 »

There are no direct equivalents in ImageMagick (thus not in Imagick) for these outputs. But you should be able to figure out the transformations and find the proper ImageMagick commands to combine to make the equivalent. In ImageMagick, you could create a 3D HALD image as PNG. Take it to Photoshop. Process the hald image to make the effect you want. Then bring the HALD image back to ImageMagick and use -hald-clut command to process any image to do the same. See https://www.imagemagick.org/Usage/color_mods/#hald-clut. In Imagick, see http://us3.php.net/manual/en/imagick.haldclutimage.php
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hello Fred,

With using the HALD image, I can manage the PS Image black and White features as requested.

Thank you for your suggestion.
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hi Team,

My mentioned effects were working with the HALD image at the ImageMagick version 6.7 but when we have upgraded the ImageMagick version to 7.0.8 then suddenly the HALD image as per the suggestion is stopped working.

I have checked with IM command as well as Imagick commands but for both the it is not giving result same as photoshop.
Below is the input and HALD image and script & PS results.

Used the below commands for results.

IM Command:
exec("convert uploads/CloneOutput20190108040033.png hald-infrared.png -hald-clut checkIRCMD.png");

Imagick Command:
$duplicateImage = new \Imagick(realpath("CloneOutput20190108040033.png"));
$imagickPalette = new \Imagick(realpath("hald-infrared.png"));
$duplicateImage->haldClutImage($imagickPalette,Imagick::CHANNEL_DEFAULT);
$duplicateImage->writeImage("checkIR.png");

NOTE: Ihave checked black and white > preset > Infrared and also need the same for Maximum Black.

Hald Image: https://www.dropbox.com/s/yfvwxrldq0t4h ... d.png?dl=0
Input Image: https://www.dropbox.com/s/zd8zuz4uvbbwq ... 3.png?dl=0
Script Output: https://www.dropbox.com/s/m5ra9y900hbut ... D.png?dl=0
Photoshop Output: https://www.dropbox.com/s/ltxbwzjaq027k ... T.png?dl=0

Please provide your feedback on this.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adjustments > black and white > preset feature

Post by snibgo »

V7 has some differences to v6. See http://www.imagemagick.org/script/porting.php . By default, v6 operations don't include the alpha channel. By default, v7 operations do.

For your command, insert "-channel RGB" before "-hald-clut" and "+channel" after.
snibgo's IM pages: im.snibgo.com
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hello Snibgo,

My issue has been resolved with the fix you mentioned. Thank you!
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hello Snibgo,

I have one issue with the below command, ie the input image is showing Channel as RGB in photoshop and output from the below command is showing Channel as Gary in photoshop. You can see screen from URL https://www.screencast.com/t/1hxsmukgAQL.
Kindly let me know how we can fix this issue?

exec("convert CloneOutput20190108040033.png hald-infrared.png -channel RGB -hald-clut +channel checkIRCMD.png");
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adjustments > black and white > preset feature

Post by snibgo »

The result has only grayscale pixels, so IM by default stores only one channel in the PNG file. If you want 3 channels, use the "PNG24:" prefix, eg:

Code: Select all

convert CloneOutput20190108040033.png hald-infrared.png -hald-clut PNG24:x.png
snibgo's IM pages: im.snibgo.com
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hello Snibgo,

I have checked with adding "PNG24:" but it again starts giving me the bad result for my image and now I am getting output as given in below URL.
https://www.dropbox.com/s/m5ra9y900hbut ... D.png?dl=0

I have ran the below two commands but getting same result as mentioned in above URL.
exec("convert CloneOutput20190108040033.png hald-infrared.png -channel RGB -hald-clut +channel PNG24:2x.png");
And
exec("convert CloneOutput20190108040033.png hald-infrared.png -hald-clut PNG24:4x.png");
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adjustments > black and white > preset feature

Post by snibgo »

What version of IM are you using? For v7, I suggest you use "magick", not "convert". For both v6.9.9-50 and v7.0.7-28, PNG24: gives me a png with three 8-bit channels.
snibgo's IM pages: im.snibgo.com
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hi Snibgo,

I am using IM 7.0.8 version at the CentOS server.
Using the below command but still getting the issue with background is not as expected. Please suggest.

exec("magick CloneOutput20190108040033.png hald-infrared.png -channel RGB -hald-clut +channel PNG24:5x.png");
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hello Team,

It will be good if any one please provide any suggestion on my above query.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adjustments > black and white > preset feature

Post by fmw42 »

You post an input image with transparency replaced by a checkerboard. If your input image has transparency, then post that image with actual transparency.
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Adjustments > black and white > preset feature

Post by mjamal »

Hi Fred,

I have sent you the input images via email, please check and let me know if its fine with you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adjustments > black and white > preset feature

Post by fmw42 »

Please post your images here so others, too, can help solve your problem.
Post Reply