Created attachment 409031 [details] Incorrectly rendered WebP image WebKit supports WebP images in iOS 14, but ICC profile support seems to be broken. I've attached an example WebP image that isn't rendered correctly in Safari. This is also filed as feedback FB7793986.
Created attachment 409032 [details] Expected image Here (as a PNG image) is the expected output for the WebP image.
rdar://64790996
It looks like Chrome on iOS 14 and UIImage on iOS 14 have the same problem: it seems like an ICC profile in a WebP gets ignored, causing e.g. images with the Display P3 profile to look desaturated (presumably because they are misinterpreted as sRGB). I don't have access to the Core Image source code so I don't know how WebP suppport was implemented, but it's quite easy to forget about ICC profiles. To not ignore the ICC profile, you need to not just call the simple one-stop high-level decode function WebPDecodeRGBA(), but you also need to include webp/demux.h and do something like this: WebPDemuxer* demux = WebPDemux(&webp_data); uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS); // ... (Extract metadata). WebPChunkIterator chunk_iter; if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter); // ... (Consume the ICC profile in 'chunk_iter.chunk'). WebPDemuxReleaseChunkIterator(&chunk_iter); WebPDemuxDelete(demux); I hope this helps and we can avoid having to convert/clamp WebP images to the sRGB gamut!
I had filed FB8759612 similarly for Mac OS. Not much more to add except the original webkit patch and a few other links, from the feedback assistant: --- https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/testing/data/webp-color-profile-lossy.webp WebP images can contain an embedded ICC profile that affects the rendering of the final image. Here are some relevant links to an old webkit patch and the tracking bug for chrome: https://bugs.webkit.org/show_bug.cgi?id=112747 https://bugs.chromium.org/p/chromium/issues/detail?id=172308 The ‘purpur’ text should be purple in this image. See the jpg for reference: https://houz.org/tmp/farbkreis.jpg