Issue with "-gamma" operator in IM 7...

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Issue with "-gamma" operator in IM 7...

Post by GeeMack »

Using IM 7.0.6-0 HDRI on Windows 10 64...

The "-gamma" operator, according to this LINK and this LINK, should allow for adjusting the gamma separately for each of the R, G, and B channels. Using IM 7.0.6-0, the first argument to "-gamma" adjusts all channels, and any following arguments are ignored. The output of the following commands, although they should produce different results, are identical...

Code: Select all

magick logo: -gamma 1,1,1 result_111_v7.png

magick logo: -gamma 1,1,2 result_112_v7.png

magick logo: -gamma 1,2,2 result_122_v7.png
These two commands should not generate identical results, but they do...

Code: Select all

magick logo: -gamma 2 result_1arg.png

magick logo: -gamma 2,1,1 result_3args.png
With the following commands using IM 6.9.8-10, the gamma adjustment is done on a per channel basis as expected...

Code: Select all

convert logo: -gamma 1,1,1 result_111_v6.png

convert logo: -gamma 1,1,2 result_112_v6.png

convert logo: -gamma 1,2,2 result_122_v6.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with "-gamma" operator in IM 7...

Post by fmw42 »

For IM 7, try adding -channel rgb before -gamma. Does that help? I would hope that it would not be necessary to do that. But IM 7 sometimes needs an explicit -channel settings.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Issue with "-gamma" operator in IM 7...

Post by GeeMack »

fmw42 wrote: 2017-07-14T08:50:57-07:00For IM 7, try adding -channel rgb before -gamma. Does that help? I would hope that it would not be necessary to do that. But IM 7 sometimes needs an explicit -channel settings.
No change. I can't find a way to make the "-gamma" operator act on the color channel arguments as described in the docs. With one argument, it adjusts the gamma for all channels. With more than one argument it will still adjust all channels according to the first argument and ignore the rest.

This has been an issue since at least v7.0.5 as I described in THIS post. The only way to get it to act on individual channels is to work it with something like "... -channel R -gamma 1.23 +channel ..." for each color, but that seems like it shouldn't be necessary. This is a function I've used occasionally since IM6, and it still works as expected in IM6. It would be disappointing if this color channel functionality has been removed in IM7.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with "-gamma" operator in IM 7...

Post by fmw42 »

If my suggestion did not work, then this is a bug. I have confirmed at least one of your commands in IM 7 does not behave correctly.

Code: Select all

magick logo: -gamma 1,2,2 result_122_v7.png
and one of the developers needs to check it
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issue with "-gamma" operator in IM 7...

Post by magick »

Try this command:

Code: Select all

magick logo: -channel blue -gamma 2 result_112_v7.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with "-gamma" operator in IM 7...

Post by fmw42 »

magick wrote: 2017-07-14T17:54:48-07:00 Try this command:

Code: Select all

magick logo: -channel blue -gamma 2 result_112_v7.png
Has -gamma changed in IM 7? Does it not allow 3 arguments for different values for each channel?

This does not work:

Code: Select all

magick logo: -channel rgb -gamma 1,2,2 result_122_v7.png
I treats all channels the same as if with -gamma 1 and is ignoring the other arguments. I do not see anything about changes to -gamma in the porting docs.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issue with "-gamma" operator in IM 7...

Post by magick »

The three argument -gamma option is not supported in IMv7 as a consequence of the enhanced channel handling supported in IMv7 vs IMv6. The change is now documented in the porting guide @ https://www.imagemagick.org/script/porting.php. To modify the channels with different gamma settings in IMv7, use:

Code: Select all

magick logo: -channel red -gamma 0.8 -channel green -gamma 1.2 -channel blue 1.6 result_122_v7.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with "-gamma" operator in IM 7...

Post by fmw42 »

Thanks for the clarification
Post Reply