Prajwal
Prajwal

Reputation: 673

Does Python PIL support converting jpg to webp with all support that cwebp has?

I am converting jpg to webp format using cwebp tool provided in official doc. I am checking if PIL library supports converting images from jpg to webp with all the support cwebp CLI has? like -lossless or quality -q.

I am asking this because I didn't see any documentation for the same.

Thanks.

Upvotes: 0

Views: 699

Answers (1)

Cees Timmerman
Cees Timmerman

Reputation: 19664

https://github.com/python-pillow/Pillow/blob/main/docs/handbook/image-file-formats.rst#webp states:

WebP

Pillow reads and writes WebP files. The specifics of Pillow's capabilities with this format are currently undocumented.

Saving

The PIL.Image.Image.save method supports the following options:

lossless

: If present and true, instructs the WebP writer to use lossless compression.

quality

: Integer, 0-100, defaults to 80. For lossy, 0 gives the smallest size and 100 the largest. For lossless, this parameter is the amount of effort put into the compression: 0 is the fastest, but gives larger files compared to the slowest, but best, 100.

alpha_quality

: Integer, 0-100, defaults to 100. For lossy compression only. 0 gives the smallest size and 100 is lossless.

method

: Quality/speed trade-off (0=fast, 6=slower-better). Defaults to 4.

exact

: If true, preserve the transparent RGB values. Otherwise, discard invisible RGB values for better compression. Defaults to false. Requires libwebp 0.5.0 or later.

icc_profile

: The ICC Profile to include in the saved file. Only supported if the system WebP library was built with webpmux support.

exif

: The exif data to include in the saved file. Only supported if the system WebP library was built with webpmux support.

xmp

: The XMP data to include in the saved file. Only supported if the system WebP library was built with webpmux support.

Upvotes: 1

Related Questions