This is really cool, but I found one thing in testing it out: it seems to do really poorly with WebP images.

I've run some WebP images from reddit through your site and they all end up looking terrible. If I run them through Squoosh.app (MozJPEG, 75%), I get the expected minimal degradation in quality and a 30%ish reduction in size. If I run the same image through your site (which seems hard-coded to Q90 for quality), I get a minimal reduction in size (if any; to be expected given Q90) and it looks incredibly pixelated.

If I give it a jpeg, it works great: a large reduction in size and I can't even notice a difference (which is kinda what I expect for Q90).

EDIT: If I toggle on the "legacy mode" YCbCr (instead of XYB), the WebP files work great. If I get the jpeg from reddit instead of the webp, XYB is fine.

Try an image like https://www.reddit.com/r/PeterExplainsTheJoke/comments/1o8wo... (you can right click and download the image to get the webp or "download linked file" to get the jpeg). If I put the jpeg into your site with XYB, there's very slight degradation and a 67% savings. If I put the webp in, it looks like it was resized to half or a quarter of the size and then enlarged back up (and it gained 57%). With webp and YCbCr, it gained 63% over the webp, but the image quality is good.

So there's something with the WebP images and XYB that seems like it isn't working.

EDIT 2: I just grabbed an AVIF I have around to test and the XYB seems to have the same problem there as well.

Can I ask which browser you're using?

I was unable to reproduce the exact same issue you described here on Firefox 128 on Linux... however, you're definitely onto something!

It's a combination of two subtle issues:

1) A known bug in the jpegli library. As you suspected, XYB mode combined with chroma subsampling (like the old 4:2:0 default) can cause the exact "downscaled" look you saw. [0]

2) A sizing bug in my decoder pipeline. I was mistakenly using an image's internal codedWidth instead of its final displayWidth. For some WebP/AVIF files, this created a smaller image on a larger canvas, which magnified the XYB bug.

I've just pushed a fix that addresses both issues. I've also updated the defaults to what I believe is a much better starting point: Quality 80, XYB, and 4:4:4 subsampling. This combination avoids the bug while still leveraging the best perceptual model, so it should prevent those surprising quality drops.

Thanks again for the incredibly detailed report-it was super helpful!

There's an unbelievable amount of edge cases with all of these different image formats. It's been a great learning experience for sure!

[0] https://github.com/google/jpegli/issues/122