Page 1 of 1

indexed 1-bit png is negated

Posted: 2015-06-05T13:41:11-07:00
by taddwit
Dear All,
If I run (on Windows 7 / ImageMagick 6.9.1-3 Q16 x86 portable)
"convert input.png -depth 1 -define png:color-type=3 output01.png" and
"convert input.png -depth 1 -negate -define png:color-type=3 output02.png"

I get two images that look the same (in my case input.png is already 1-bit / indexed); the Problem is neither there with color-type=2 nor with tif, but somehow with indexed png + 1-bit color-depth ...

identify -verbose input.png is:
Colors: 2
Histogram:
1144010: ( 0, 0, 0) #000000 gray(0)
12932969: (255,255,255) #FFFFFF gray(255)
Colormap entries: 2
Colormap:
0: (255,255,255) #FFFFFF gray(255)
1: ( 0, 0, 0) #000000 gray(0)

identify -verbose output01.png is:
Colors: 2
Histogram:
12932969: ( 0, 0, 0) #000000 gray(0)
1144010: (255,255,255) #FFFFFF gray(255)
Colormap entries: 2
Colormap:
0: (255,255,255) #FFFFFF gray(255)
1: ( 0, 0, 0) #000000 gray(0)

identify -verbose output02.png is:
Colors: 2
Histogram:
12932969: ( 0, 0, 0) #000000 gray(0)
1144010: (255,255,255) #FFFFFF gray(255)
Colormap entries: 2
Colormap:
0: ( 0, 0, 0) #000000 gray(0)
1: (255,255,255) #FFFFFF gray(255)

"mogrify -define png:color-type=3 output01.png" somehow it adds a color map entry / "identify -verbose output01.png (neu)" is:

Colors: 2
Histogram:
12932969: ( 0, 0, 0) #000000 gray(0)
1144010: (255,255,255) #FFFFFF gray(255)
Colormap entries: 3
Colormap:
0: ( 0, 0, 0) #000000 gray(0)
1: (255,255,255) #FFFFFF gray(255)
2: (254,254,254) #FEFEFE gray(254)

Re: indexed 1-bit png is negated

Posted: 2015-06-05T16:57:20-07:00
by glennrp
The extra entry is for the background color. To prevent that, use

Code: Select all

mogrify -define png:color-type=3 -define png:exclude-chunk=bKGD output01.png
Verified that the conversion to type=3 is inverting black and white. I don't know why but will
investigate.

Re: indexed 1-bit png is negated

Posted: 2015-06-06T00:28:46-07:00
by taddwit
it seems to me that it does not invert when the first pixel is black...
convert input.png -size 1x1 -fill black -draw "point 0,0" -depth 1 -define png:color-type=3 output.png

works perfectly without any negation

Re: indexed 1-bit png is negated

Posted: 2015-06-06T07:35:58-07:00
by glennrp
The bug was introduced in ImageMagick-6.8.7-9.