Closed desbma closed 1 year ago
Looks like oxipng
missed the 32-bit → palletted conversion that optipng
did. Is that choice by default, or isn't that implemented (yet)?
@TPS AFAIK oxipng does perform that conversion. You might want to add -v
flag to see more output from oxipng.
Output of oxipng -v -o6 lock.png
: https://pastebin.com/raw/U2yskz4f
optipng
:
512x512 pixels, 4x8 bits/pixel, RGB+alpha Reducing image to 8 bits/pixel, 233 colors (232 transparent) in palette
oxipng
:
512x512 pixels, PNG format 4x8 bits/pixel, RGBA Reducing image to 2x8 bits/pixel, Grayscale + Alpha
I think, instead, that the different conversion (4-byte color+ɑ → 2-byte grayscale+ɑ, instead of → paletted+tRNS
) is probably the cause of different result.
Would https://github.com/shssoichiro/oxipng/pull/199 affect this positively?
@TPS No, it's just providing more deterministic output, but not adding any new optimisations.
P.S. By the way, out of curiousity - why are you leaving reactions to your own messages? 😀
I think, instead, that the different conversion (4-byte color+ɑ → 2-byte grayscale+ɑ, instead of → paletted+tRNS) is probably the cause of different result.
This actually sounds reasonable and something we've seen in one of examples in Squoosh PR as well.
@shssoichiro It seems that OxiPNG currently assumes that grayscale is the most efficient representaton for grayscale-ish images, but paletted representation often compresses even better (e.g. in example above Grayscale+Alpha requires more space than 233 colours in a palette).
So reduction should try both grayscale and palette (or grayscale+alpha and palette). Seems like a reasonable approach. Color reduction is pretty fast so this shouldn't hurt speed much either.
I think even adding conversion for Grayscale+Alpha -> palette would already go a long way, as currently it's not attempted (it should be similar to existing RGBA -> palette - maybe possible to make the function generic somehow?).
I think even adding conversion for Grayscale+Alpha -> palette
@RReverser To be clear, do you mean Grayscale+ɑ → Pallette+tRNS
, Greyscale → Pallette, or both? I've seen that 2nd pairing come out better, as well as trying different palletted bit-depths. (I.E., sometimes deflate
's compression somehow works better w/ 8-bit than ≤4-bit pallettes.)
I was mostly referring to Grayscale alpha -> Palette as it's an easy win (and it will practically always be a win as in the worst case it's reducing 2 bytes -> 1 byte uncompressed), but other combinations might be worth looking into too.