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
Code: Select all
f0.png gamma = 0.45455
f0_out.png gamma = 1
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.