"lossless" image format is not lossless
Closed this issue ยท 5 comments
Description
When using lossless
as an image format, it's expected to be served images which are lossless, but that's not the case for webp
with the default options.
- RIPE SDK translates
lossless
towebp
when possible:Line 695 in b0b5300
- ripe-compose by default applies lossful compression when using
webp
: https://github.com/ripe-tech/ripe-compose/blob/0ffa265a375e39dceaa2ab853e25e19cf59546f0/src/ripe_compose/util/configurator.py#L84
Example:
- png: https://ripe-core-stage.platforme.com/api/compose?brand=hermes&model=h003572sv01&initials=MARTA&initials_profile=jungle_love,black,zoom&p=body:silk:01&p=shadow:default:default&size=850
- webp: https://ripe-core-stage.platforme.com/api/compose?brand=hermes&model=h003572sv01&initials=MARTA&initials_profile=jungle_love,black,zoom&p=body:silk:01&p=shadow:default:default&size=850&format=webp
Woof, Woof!
Thank you for submitting the ""lossless" image format is not lossless" issue ๐.
Please do not forget to review our internal guidelines:
- Describe the problem in the best possible way
- Include at least the
Description
section, but considered adding other sections - Avoid suggesting immediate solutions, think deeply about the problem
- Engage in the Triage process being as responsive as possible
- Understand and accept the possibly large amount of execution time
- Avoid immediate reallocation of the issue, let triage do their job
Engaging in the development process in the best possible way helps it being efficient and fast.
Your friend,
Tobias (Platforme's mascot)
Let's not be strict here "Lossless == Almost lossless" ๐
Now seriously nice catch
Let's make default webp options lossless and measure the impact in image size, then discuss on this one
After a deeper investigation I've come to realize that this could not be fixed by increasing the quality = 100
(currently at 95) implemented here - the quality degradation from changing 95 -> 100 looked visually imperceptible to my eyes.
The buggy "blur" effect, mostly evident on the initials "MARTA" is being caused by the python imaging library most specifically the PIL.WebPImagePlugin
which we use when saving the image composition at image.save for webp format. This WebPImagePlugin has lossless at false by default and that was the cause of this blur effect.
Below are the image compositions
- | - |
---|---|
current webp at 90% quality = 247.27 kb | |
lossless webp at 95% quality = 913.13 kb | |
lossless webp at 100% quality = 913.6 kb | |
png = 1.27 MB |
I'm creating a PR for the 2nd option lossless webp at 95% quality = 913.13 kb