Issue 340 in webp: Colors get distorted when cwebp converts png to webp

567 views
Skip to first unread message

adi… via monorail

unread,
Mar 25, 2017, 2:43:52 AM3/25/17
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 340 by adi...@patadia.org: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340

What steps will reproduce the problem?
1. Get the test.png image from this source: https://drive.google.com/file/d/0B8IHowt1-H64SVRXVzUyQjFfekE/view?usp=sharing
2. Use 0.6.0 version of cwebp to convert to webp image
3. Resultant image will be this one: https://drive.google.com/file/d/0B8IHowt1-H64dFdabGRiR0FTSms/view?usp=sharing

What is the expected output? What do you see instead?

You can see that the background on original image is of color #FOFOFO. The background on converted image is #FOFOFO on top side but as you come below, the background becomes #F1EFF2.

What version of the product are you using? On what operating system?

0.6.0 version of cwebp. Tried on Linux and MacOS with pre compiled binaries and also compiled on my own. Both gives same results.

Please provide any additional information below.




--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

adi… via monorail

unread,
Mar 25, 2017, 3:12:42 AM3/25/17
to webp-d...@webmproject.org

Comment #1 on issue 340 by adi...@patadia.org: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c1

Attaching file here itself.

Attachments:
test.png 881 KB
test.webp 235 KB

adi… via monorail

unread,
Mar 25, 2017, 3:14:52 AM3/25/17
to webp-d...@webmproject.org

Comment #2 on issue 340 by adi...@patadia.org: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c2

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 not happen.

njdo… via monorail

unread,
Mar 25, 2017, 8:05:39 AM3/25/17
to webp-d...@webmproject.org

Comment #3 on issue 340 by njdo...@gmail.com: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c3

This kinda smells like Issue 308.

adi… via monorail

unread,
Mar 25, 2017, 8:17:50 AM3/25/17
to webp-d...@webmproject.org

Comment #4 on issue 340 by adi...@patadia.org: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c4

Indeed. I confirm when I set q=85, it outputs perfect image without color distortion. This is a very big problem considering so many people might be using normal cwebp encoder without quality parameter and getting this distortion since it defaults to q=75.

I hope Issue 308 gets fixes asap.

pascal.m… via monorail

unread,
Mar 25, 2017, 11:53:40 AM3/25/17
to webp-d...@webmproject.org

Comment #5 on issue 340 by pascal.m...@gmail.com: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c5

default encoding parameter for 'cwebp' is to use lossy encoding.
This means that small (hopefully unnoticeable) differences between source and compressed images are unavoidable. The differences are smaller and smaller in amplitude as one raises the -q parameter value.
Still, even at q=100, one can get a +/-1 difference (mostly because of the colorspace transfer: RGB <-> YUV, which incurs some rounding error).

You would obverse similar difference if compressing to JPEG format.

If the difference is too large, one solution is to raise the -q parameter, to 85 for instance.
Alternatively, if you want to guarantee a minimum level of distortion, you can use the option '-psnr 40' or more (like: '-psnr 42').

Regarding issue #308: yes, this is a similar problem. Note however that in bug #308 the problem is exacerbated because the initial gray value is around #80, an area where the human visual system is most sensitive.
For values saturated above #f0, the effect of lossy compression is somewhat harder to spot.

adi… via monorail

unread,
Mar 27, 2017, 3:35:22 AM3/27/17
to webp-d...@webmproject.org

Comment #6 on issue 340 by adi...@patadia.org: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c6

As per I understand, cwebp uses lossy compression at q=75 in default mode. Now there will be lot of people who would use this default mode while encoding to webp thinking it will have unnoticeable difference.

In reality the shift towards pink shade occurs which according to me is not acceptable. I am no expert in image compression and formats but as end user, this thing matters a lot.

Think about me converting all images to webp in my company with the cwebp tool only to realise later that it modified all my files in noticeable way. If you compare with other lossy compression for PNG or JPG, none modify images in such drastic way.

s… via monorail

unread,
Dec 8, 2017, 8:40:17 AM12/8/17
to webp-d...@webmproject.org

Comment #7 on issue 340 by sk...@google.com: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c7

update: this patch https://chromium-review.googlesource.com/#/c/webm/libwebp/+/813774/ will likely help in this case (see attached, the new version).

However, that patch will current be restricted to quality <= 30. Before extending it to higher quality, we need to assess the impact on filesize and speed (and possible use 'lighter' algo that still does the job at q >= 50 for difficult cases).



Attachments:
test1_new.webp 236 KB

bugdro… via monorail

unread,
Jan 5, 2018, 5:52:18 PM1/5/18
to webp-d...@webmproject.org

Comment #8 on issue 340 by bugd...@chromium.org: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c8

The following revision refers to this bug:
https://chromium.googlesource.com/webm/libwebp/+/815652de03377339aee55f048dd41f581853f0ef

commit 815652de03377339aee55f048dd41f581853f0ef
Author: Pascal Massimino <pascal.m...@gmail.com>
Date: Wed Dec 27 20:11:57 2017

enable dc error-diffusion always

for q<=98, we always enable error diffusion.

+ reduce storage 2x by using int8_t
+ make the error diffusion more robust

BUG=webp:340,308

Change-Id: I0608df839ff7b64d6843005a0f81d2577143af9e

[modify] https://crrev.com/815652de03377339aee55f048dd41f581853f0ef/src/enc/quant_enc.c
[modify] https://crrev.com/815652de03377339aee55f048dd41f581853f0ef/src/enc/vp8i_enc.h

pascal.m… via monorail

unread,
Apr 3, 2018, 7:04:06 AM4/3/18
to webp-d...@webmproject.org
Updates:
Owner: pascal.m...@gmail.com
Status: Fixed

Comment #9 on issue 340 by pascal.m...@gmail.com: Colors get distorted when cwebp converts png to webp
https://bugs.chromium.org/p/webp/issues/detail?id=340#c9

closing this bug.

In libwebp-1.0.0, encoding now behaves better, even with quality as low as -q 10.
(cf. attachement).

Attachments:
out.webp 133 KB
Reply all
Reply to author
Forward
0 new messages