WebP is a modern image format that provides superior lossless and lossy compression for images on the web. It was developed by Google, and is designed to be smaller in size than other image formats, while still maintaining high image quality.
One reason WebP is often considered better than JPEG is that it can achieve significantly smaller file sizes for images with the same visual quality. This is because WebP uses more advanced compression techniques than JPEG, which allows it to reduce the size of the image data without sacrificing quality. This can be especially useful for websites, as smaller image sizes can lead to faster page load times and a better user experience.
In addition to its smaller file size, WebP also has other advantages over JPEG. It supports both lossless and lossy compression, so you can choose the right balance of file size and image quality for your needs. WebP also supports transparency, which can be useful for graphics and logos.
Overall, WebP is a modern image format that can provide improved compression and faster page load times, making it a good choice for use on the web.
Conversion with Pillow
Pillow supports webp as well. The cool thing is that the conversion can be done in a couple of lines:
def test_convert_to_webp(): source = Path("pillow_webp-fi.jpg") destination = source.with_suffix(".webp") image = Image.open(source) image.save(destination, format="webp") path_webp = Path("pillow_webp-fi.webp") assert path_webp.exists()
After conversion the image size is cut in half (7.3 MB to 3.6MB) without any visual artifacts of compression.