GDLibrary webp Quality Control?

Right now we are using GDLibrary to create images dynamically and are using:

imagejpeg at 68 quality. It works great.

We want to use imagewebp to satisfy google and speed up page loads. The only problem is that half the time the webp file is larger than the jpeg file; which is exactly the opposite of what webp should do.

We would love to lower the quality on imagewebp, but can’t find a way. Is there any way to lower a quality through GDLibrary for imagewebp() function?

All feedback appreciated.

Actually, wait, I just copied the same function structure for imagejpeg to imagewebp:

imagewebp($thumb,NULL, 64);

And not only did it work but it delivered a smaller webp file size.

Why is this not mentioned in documentation?

I’ve never used webp but this is what I found in Wikipedia:

Like VP8 on which it is based, lossy WebP only supports 8-bit YUV 4:2:0 format,[41] which may cause color loss on images with thin contrast elements (such as in pixel art and computer graphics) and ghosting in anaglyph. To overcome this restriction, new lossless WebP supports VP8L encoding that works exclusively with 8-bit ARGB color space.[42][43]

If I understand it properly, this means that chroma subsampling cannot be turned off for webp, which means that top image quality is impossible to achieve unlike in jpeg, where chroma subsampling can be turned off (however, not in GD). This is a show stopper for me - how could they omit such an important feature? A lossless version is no solution since the file size will sky-rocket for photo-like images. Sure, for thumbnails where quality is not important this is not a problem but otherwise it might be. I thought Google invented a new excellent successor to jpeg but apparently it’s not true (yet).

Thanks for input Lemon_Juice. Our first implementation is for thumbnails and images no larger than 780px wide; on that 16:9 size we are seeing that webp comes in about 18% smaller file size than our GDLibrary output jpeg.

We are going to start using GDLibrary to make webp versions of higher resolution posters and actual movie stills (so like photos), so I’m expecting we will probably encounter this issue then.


Actually, it’s often quite the opposite - chroma subsampling, which is effectively lossy compression of fine colour detail, is more noticeable on small images because when you present a large image then usually people don’t stare at it from a close distance where the finest colour detail is visible. Movie stills usually are not laser-sharp so they shouldn’t lose much from chroma subsampling. And in many cases chroma subsampling is a good thing because it can lessen the file size.

When using GD you can’t produce jpegs without chroma subsampling anyway, so I suppose webp will look better in comparison.

But mind you - I am a bit nuts about such things and notice details that don’t bother most other people - so you may very likely never find anything wrong with the quality of your images :smiley:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.