siiptuo / pio

Optimize images while maintaining the same perceived quality
138 stars 10 forks source link

Support discarding transparency #25

Closed adworacz closed 3 years ago

adworacz commented 3 years ago

While testing out pio I realized that discarding transparency from my PNG images when converting with cwebp using -noalpha substantially decreased the size of the output images, surpassing pio's output with the same quality settings.

The PNG's of my source are just screenshots, where alpha/transparency information is useless.

Would love to convert my images using pio and use a similar --no-alpha option!

Thank you for your fine work!

siiptuo commented 3 years ago

Thank you for testing out pio!

Would love to convert my images using pio and use a similar --no-alpha option!

The development version has --no-transparency option so this will be possible in the next version.

The PNG's of my source are just screenshots, where alpha/transparency information is useless.

Do your images include transparency like drop shadow in macOS screenshots? In the current version, webp files shouldn't contain alpha channel if the input doesn't have one or all pixels are non-transparent.

adworacz commented 3 years ago

It’s a good question - my images were taken using maim on an Archlinux laptop. There shouldn’t be any associated drop shadow, etc.

Happy to provide a sample for testing, if a bug is suspected.

siiptuo commented 3 years ago

Can you run the following commands with your input image and output from pio:

identify -format '%[channels],%A,%[opaque]' input.png
identify -format '%[channels],%A,%[opaque]' output.webp

(requires ImageMagick)

adworacz commented 3 years ago

Okay, I don't know what I was smoking yesterday. Rerunning my tests and now pio is producing smaller results than cwebp, even when I configure the latter to remove alpha transparency...

Here's the results you asked for:

╰─ identify -format '%[channels],%A,%[opaque]' test.png
srgba,Blend,True%
╰─ identify -format '%[channels],%A,%[opaque]' test.webp
srgb,Undefined,True%

So yeah, it looks like pio is properly removing transparency.

I have no idea how I got the results I did yesterday....

I think this issue can be closed, especially since you said the next version will offer a --no-transparency flag.

siiptuo commented 3 years ago

No problem! Great to see it works as expected.