PNG transparency

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
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

PNG transparency

Post by GreenKoopa »

At least I think this has to do with PNG, transparency, or palettes. Maybe +level? What is going on here? I notice "PseudoClass 256c" frequently. All images here should have exactly 2 colors.

My apologies for the length. There are only two converts, attempted 4 times slightly differently. I added an identify and histogram after each step for debugging info.

----- Generate an example 1-bit mask -----
This is an example of a mask given as the starting point.

> convert -size 100x50 xc:white xc:black -append -define png:color-type=3 in.png
> identify in.png
in.png PNG 100x100 100x100+0+0 8-bit PseudoClass 2c 253B 0.000u 0:00.000
> convert in.png -format %c histogram:info:
5000: ( 0, 0, 0) #000000 black
5000: (255,255,255) #FFFFFF white

----- Attempt 1: fail -----

> convert in.png -alpha Copy -evaluate Set 40000 a.png
> identify a.png
a.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 359B 0.000u 0:00.001
> convert.exe a.png -format %c histogram:info:
5000: (156,156,156, 0) #9C9C9C00 graya(156,156,156,0)
5000: (156,156,156,255) #9C9C9C grey61

> convert a.png -channel a +level 50,100% +channel b.png
> identify b.png
b.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 349B 0.000u 0:00.000
> convert b.png -format %c histogram:info:
10000: (156,156,156,127) #9C9C9C7F graya(156,156,156,0.498039)

----- Attempt 2: fail -----
Maybe this is a PNG palette or transparency problem, so trying explicit Gray-Matte.

> convert in.png -alpha Copy -evaluate Set 40000 -define png:color-type=4 a.png
> identify a.png
a.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 359B 0.000u 0:00.000
> convert a.png -format %c histogram:info:
5000: (156,156,156, 0) #9C9C9C00 graya(156,156,156,0)
5000: (156,156,156,255) #9C9C9C grey61

> convert a.png -channel a +level 50,100% +channel b.png
> identify b.png
b.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 349B 0.000u 0:00.000
> convert b.png -format %c histogram:info:
10000: (156,156,156,127) #9C9C9C7F graya(156,156,156,0.498039)

----- Attempt 3: pass -----
Maybe RGBA then?

> convert in.png -alpha Copy -evaluate Set 40000 PNG32:a.png
> identify a.png
a.png PNG 100x100 100x100+0+0 8-bit DirectClass 481B 0.000u 0:00.000
> convert a.png -format %c histogram:info:
5000: (156,156,156, 0) #9C9C9C00 rgba(156,156,156,0)
5000: (156,156,156,255) #9C9C9C grey61


> convert a.png -channel a +level 50,100% +channel b.png
> identify b.png
b.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 358B 0.000u 0:00.000
> convert b.png -format %c histogram:info:
5000: (156,156,156, 0) #9C9C9C00 graya(156,156,156,0)
5000: (156,156,156,127) #9C9C9C7F graya(156,156,156,0.498039)

----- Attempt 4: pass -----
Maybe this was a problem with +level?

> convert in.png -alpha Copy -evaluate Set 40000 a.png
> identify a.png
a.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 359B 0.000u 0:00.001
>convert a.png -format %c histogram:info:
5000: (156,156,156, 0) #9C9C9C00 graya(156,156,156,0)
5000: (156,156,156,255) #9C9C9C grey61

> convert a.png -channel a -evaluate multiply 0.5 +channel b.png
> identify b.png
b.png PNG 100x100 100x100+0+0 8-bit PseudoClass 256c 358B 0.000u 0:00.000
> convert b.png -format %c histogram:info:
5000: (156,156,156, 0) #9C9C9C00 graya(156,156,156,0)
5000: (156,156,156,127) #9C9C9C7F graya(156,156,156,0.498039)
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: PNG transparency

Post by GreenKoopa »

ImageMagick is in a folder labeled 6.6.6-2 but reports as 6.6.6-3 2010-12-01 Q16.

A seeming related problem:
viewtopic.php?f=3&t=17635
Maybe this one too, but harder to tell:
viewtopic.php?f=1&t=17597
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG transparency

Post by glennrp »

Verified that attempts 1 and 2 fail with the latest (6.6.6-3) both Q8 and Q16 builds (I changed 40000 to 61% so it would run on both builds).
Post Reply