Page 1 of 1

PNG transparency

Posted: 2010-12-07T13:45:14-07:00
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)

Re: PNG transparency

Posted: 2010-12-07T18:19:22-07:00
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

Re: PNG transparency

Posted: 2010-12-07T22:35:24-07:00
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).