-flatten causes gamma-shift

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
snibgo
Posts: 10357
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

-flatten causes gamma-shift

Post by snibgo » 2014-12-14T09:52:54-07:00

A new bug was introduced sometime between 6.8.9-5 and 6.9.0-0. (Windows 8.1, Q16 binary distribution.)

For greyscale inputs, "-flatten" causes a shift in the gamma value, from 1/2.2 to 1.

Test case:

Code: Select all

convert -size 1x1 xc:#888 f0.png

convert f0.png -background Red -flatten f0_out.png

identify -format "f0.png gamma = %%[gamma]\n" f0.png

identify -format "f0_out.png gamma = %%[gamma]\n" f0_out.png
Results:

Code: Select all

f0.png gamma = 0.45455
f0_out.png gamma = 1
"-layers flatten" shows the same problem.

The problem occurs only when the input contains no colour. If the input contains transparency, so the flatten introduces colour, the gamma is shifted to 1.
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 10823
Joined: 2003-05-31T11:32:55-07:00

Re: -flatten causes gamma-shift

Post by magick » 2014-12-14T10:49:36-07:00

6.9.0-1 Beta has this ChangeLog entry:
  • 2014-11-20 6.9.0-1 Glenn Randers-Pehrson <glennrp@image...>
    * Don't override gamma with 1.0 when reading a grayscale PNG image (reference
    viewtopic.php?f=3&t=26576).

snibgo
Posts: 10357
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -flatten causes gamma-shift

Post by snibgo » 2014-12-14T10:56:55-07:00

Ah, yes, it's probably the same bug, so is probably now fixed. Thanks.
snibgo's IM pages: im.snibgo.com

Post Reply