indexed 1-bit png is negated

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
taddwit
Posts: 2
Joined: 2015-06-05T11:29:29-07:00
Authentication code: 6789

indexed 1-bit png is negated

Post 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)
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: indexed 1-bit png is negated

Post 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.
taddwit
Posts: 2
Joined: 2015-06-05T11:29:29-07:00
Authentication code: 6789

Re: indexed 1-bit png is negated

Post 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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: indexed 1-bit png is negated

Post by glennrp »

The bug was introduced in ImageMagick-6.8.7-9.
Post Reply