Issue 401 in webp: tiff w/ alpha -> lossless WebP results in distorted alpha channel

20 views
Skip to first unread message

geop… via monorail

unread,
Oct 10, 2018, 12:47:37 PM10/10/18
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 401 by geop...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401

If you convert the attached tiff file into a lossless WebP using cwebp as follows:

cwebp -lossless test.tiff -o test.tiff.webp

then the resulting webp file will not look identical to the input file. Specifically, it appears that the two images diff in their alpha channel values. Interestingly enough, if the -lossless is removed to switch to lossy mode, the problem with the alpha channel goes away.

The cwebp version is 1.0.0.

Attachments:
test.tiff 1.4 KB
test.tiff.webp 1.5 KB

--
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

geop… via monorail

unread,
Oct 10, 2018, 12:56:54 PM10/10/18
to webp-d...@webmproject.org

Comment #1 on issue 401 by geop...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c1

Actually, I take back the lossy not having a problem. They both (lossless & lossy webp) have a problem. So this might be an issue with how cwebp is reading the tiff file.

pascal.m… via monorail

unread,
Oct 11, 2018, 7:53:55 AM10/11/18
to webp-d...@webmproject.org
Updates:
Owner: pascal.m...@gmail.com
Status: Accepted

Comment #2 on issue 401 by pascal.m...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c2

The original TIFF contains sample that are non-associated (ie: not premultiplied): the TIFFTAG_EXTRASAMPLES value is 'EXTRASAMPLE_UNASSALPHA' (=2).

Is that expected? Is your TIFF viewer taking this into account?

Because if i force the WebP tiff reader to unmultiply (as if the tag was EXTRASAMPLE_ASSOCALPHA), i get an output similar to your expectation (i think. See attachment).

Could you clarify if the input samples are premultiplied or not?

thanks!


Attachments:
test.tiff.unassoc.webp 1000 bytes

geop… via monorail

unread,
Oct 12, 2018, 6:05:40 AM10/12/18
to webp-d...@webmproject.org

Comment #3 on issue 401 by geop...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c3

I am not sure what is going on here and whether it is related to the ASSOCALPHA/UNASSALPHA thing.

My original test.tiff was created from scratch with GIMP.

Your image (test.tiff.unassoc.webp) does look like what I see when I open test.tiff with GIMP and what I expected the webp to look like.

I did some tests and it appears that different programs interpret test.tiff differently. If you look at side-by-side.png that I uploaded, I found that GIMP & ImageMagick display test.tiff like the left part of side-by-side.png, whereas GThumb & Eye of GNOME display it more like the right part. Also, cwebp produces a webp that looks like the right image whereas when I convert to webp using imagemagick I get the left image.

Attachments:
side-by-side.png 2.1 KB

pascal.m… via monorail

unread,
Oct 12, 2018, 3:48:47 PM10/12/18
to webp-d...@webmproject.org

Comment #4 on issue 401 by pascal.m...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c4

Thanks for the extra explanations.

First things first, i *think* there is a bug in ImageMagick.
I proposed a patch here:
https://github.com/ImageMagick/ImageMagick/pull/1349

Let's see where it leads.

pascal.m… via monorail

unread,
Oct 12, 2018, 7:30:40 PM10/12/18
to webp-d...@webmproject.org

Comment #5 on issue 401 by pascal.m...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c5

The ImageMagick patch has been accepted and merged[1].

It seems that the TIFF reader was buggy there. It should now be aligned to what WebP is doing.

Next: have a look at what GIMP is doing :)


[1] https://github.com/ImageMagick/ImageMagick/commit/93cb7fcfa30026f87fb8f0ccab9ad520a184cc6c

pascal.m… via monorail

unread,
Oct 14, 2018, 6:29:54 PM10/14/18
to webp-d...@webmproject.org

Comment #6 on issue 401 by pascal.m...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c6

one more data point: Eye Of Gnome is based on gdk-pixbuf for image loading.
And it seems gdk-pixbuf is not supporting alpha properly during TIFF loading.
Will try to fix that by sending a patch.

necro… via monorail

unread,
Aug 8, 2021, 1:49:23 AMAug 8
to webp-d...@webmproject.org

Comment #8 on issue 401 by necro...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c8

Converting losslessly sample file above with 1.2.1rc2 to webp gave 236 colors instead of 1 in Irfanview, not to mention it looks different than original file

pasca… via monorail

unread,
Aug 11, 2021, 10:57:13 AMAug 11
to webp-d...@webmproject.org

Comment #9 on issue 401 by pasca...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c9

could you elaborate a bit? None of the bugs above were related to libwebp, but how the tools were decoding the TIF file. What commands did you use exactly?

necro… via monorail

unread,
Aug 11, 2021, 9:28:17 PMAug 11
to webp-d...@webmproject.org

Comment #10 on issue 401 by necro...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c10

If you asked me - "cwebp -quiet -pass 10 -alpha_method 1 -alpha_filter best -m 6 -mt -lossless "test.tiff" -o "test.webp"
And OK what viewer decodes this sample OK?

jz… via monorail

unread,
Aug 12, 2021, 9:31:48 PMAug 12
to webp-d...@webmproject.org

Comment #11 on issue 401 by jz...@google.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c11

It sounds like comment #8 is related to https://crbug.com/webp/536. Let's move the conversation there.

pasca… via monorail

unread,
Aug 16, 2021, 2:46:03 PMAug 16
to webp-d...@webmproject.org

Comment #12 on issue 401 by pasca...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c12

#11 i think the problem is actually different.

I've found this old conversation from 2012 [1] reporting that GIMP is saving badly formatted TIFF files, and ImageMagick is also erroneous.
Still investigating... The patch [2] i proposed is probably incorrect.

[1] https://lists.osgeo.org/pipermail/gdal-dev/2012-May/032984.html
[2] https://chromium-review.googlesource.com/c/webm/libwebp/+/3093999

pasca… via monorail

unread,
Aug 16, 2021, 3:09:44 PMAug 16
to webp-d...@webmproject.org

Comment #13 on issue 401 by pasca...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c13

I'm proposing https://github.com/GNOME/gimp/pull/34
Let's see...

pasca… via monorail

unread,
Aug 16, 2021, 7:10:45 PMAug 16
to webp-d...@webmproject.org

Comment #14 on issue 401 by pasca...@gmail.com: tiff w/ alpha -> lossless WebP results in distorted alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=401#c14

Which version of GIMP did you use? Did you check the "save alpha" button?
Reply all
Reply to author
Forward
0 new messages