question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebP Color Discrepancy

See original GitHub issue

Describe the bug Map tiles loaded by Java using the TwelveMonkeys WEBP ImageIO reader have inconsistent colors. The file is converted from a PNG file which is all “ocean” pixels with sRGB values of (112, 173, 215). The WEBP codec returns different values, which vary slightly based on whether there are other non-“ocean” pixels in the map tile. The most common codec color for the loaded WEBP is an sRGB of (111, 165, 202).

Version information

  1. The version of the TwelveMonkeys ImageIO library in use.

It happens in both the 3.7.1 version and the 3.8-SNAPSHOT version (which includes the fix to #609)

  1. The exact output of java --version (or java -version for older Java releases).

openjdk 14.0.2 2020-07-14 OpenJDK Runtime Environment (build 14.0.2+12-46) OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

  1. Extra information about OS version, server version, standalone program or web application packaging, executable wrapper, etc. Please state exact version numbers where applicable.

MacOS 11.5.1 x86_64, run from Netbeans 12.4 directly as an executable application.

To Reproduce

This WEBP file loads correctly in web browsers but the colors are off in Java: https://www.runningreality.org/lib/map/tiles/8/136/97.webp

The file is converted from this PNG file: https://www.runningreality.org/lib/map/tiles/8/136/97.png

The conversion was done using the command: cwebp -m 6 -q 85 -mt -af -progress -sharp_yuv

Expected behavior Expect the WEBP to load with the exact color values as the PNG.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
garthhenningcommented, Aug 26, 2021

That seems to have eliminated 99% of the issue! The map tiles are all rendering with the correct colors, except for a small handful (5 out of about >150 checked so far). I’ll see if there is anything specific about those images that causes the problem. Still, those tiles that are off are off by only a tiny amount that is only noticeable because they are map tiles arranged adjacent to other correct tiles. (Attached is a pic of four tile intersection with two tiles slightly off)

Screen Shot 2021-08-26 at 3 44 57 PM
1reaction
garthhenningcommented, Aug 17, 2021

That does indeed seem like it fits all of the symptoms exactly. I can imagine that there are some circumstances where some of the integer rounding might produce a value that is off by 1 between PNG and WEBP, so that might not even technically be a bug.

I really appreciate that you are queuing up this fix. Your work to bring a solid implementation of the WEBP format to Java is of enormous benefit to the community. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

red color becomes darker after transform png to webp #1000
I'm using sharp to transform images, such as from png to webp format. some red text in ... The difference is the colour...
Read more >
Colors get distorted when cwebp converts png to webp
Please note, I used the most basic command for conversion. cwebp test.png -o test.webp. When I use -lossless option, the color distortion does...
Read more >
WebP Image Loads with incorrect color (profile? ... slight ...
The attached zip contains a webp image which when loaded with Aspose.Imaging for .NET always has a slight color difference from the original ......
Read more >
WebP images: What they are and how they are ... - Webflow
Key features of WebP image files · Lossy and lossless compression · Transparency · Animation · Metadata · Color profile.
Read more >
Using Modern Image Formats: AVIF And WebP
In this article, we'll highlight how modern image formats (AVIF or WebP) can improve compression by up to 50% and deliver better quality ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found