Re: flattening: two ways, two different results

frechefuchs via Graphicsmagick-help <[email protected]> Thu, 31 Aug 2023 08:05:44 +0200
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
Hi, Bob,

Am 30.08.23 um 21:30 schrieb Bob Friesenhahn:
> 
> Regardless, the '-operator matte assign' operation will not serve any
> purpose with it since it is desiged for RGBA TrueColor images and the
> implementation does not automatically promote a colormapped image to
> directclass.
> 
> It may be that
> 
>    gm convert logo: -type TrueColorMatte
> 
> will provide something closer to what is wanted.

That helps indeed!  I'm now doing something equivalent to

gm convert logo: PNG24:- | gm convert - -type TrueColorMatte -operator
matte assign 95% -flatten PNG24:out.png

I'm actually writing PNG48:, because the high transparency otherwise
leads to "visible" colour reduction artefacts on my original image.


> or do this to see info about the Opacity channel:

Thank you for pointing me at the info: debugging aid!

Wondering about PNG32: with a 1 bit opacity channel

> gm convert logo: PNG32:- | gm convert - -verbose info:-
> /tmp/gmVRIotL PNG 654x418+0+0 DirectClass 8-bit 52.2Ki 0.010u 0m:0.040141s (6.5Mi pixels/s)
> Image: /tmp/gmVRIotL
>   Format: PNG (Portable Network Graphics)
>   Geometry: 654x418
>   Class: DirectClass
>   Type: true color
>   Depth: 8 bits-per-pixel component
>   Channel Depths:
>     Red:      8 bits
>     Green:    8 bits
>     Blue:     8 bits
>     Opacity:  1 bits

I already got straightened by the PNG Wikipedia article:

> As stated in the World Wide Web Consortium, bit depth is defined as
> "the number of bits per sample or per palette index (not per
> pixel)".[11]
https://en.wikipedia.org/wiki/PNG#Critical_chunks

> % gm convert logo: -type TrueColorMatte -operator matte assign 50% -verbose info:-

But what is that?

> gm convert logo: PNG32:- | gm convert - -operator matte assign 50% -verbose info:-
> /tmp/gmx7zyAz PNG 654x418+0+0 DirectClass 8-bit 52.2Ki 0.010u 0m:0.046921s (5.6Mi pixels/s)
> Image: /tmp/gmx7zyAz
>   Format: PNG (Portable Network Graphics)
>   Geometry: 654x418
>   Class: DirectClass
>   Type: true color with transparency
>   Depth: 9 bits-per-pixel component        <== here
>   Channel Depths:
>     Red:      8 bits
>     Green:    8 bits
>     Blue:     8 bits
>     Opacity:  9 bits                       <== here

Shouldn't that be 8 bits?

Thanks!
fux