You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When saving a webp image, you will receive the following exception ValueError: invalid configuration. This error originates from the webp handling in Pillow here:
It expects a value between 0 and 100. Therefore quality=-1 is an invalid value for webp images.
I am working around this by defining a default quality of 75, however, I would expect the default to be usable "out of the box". If you have some guidance on how you would like this fixed I will open a PR. I have a couple ideas:
Add a special case for webp format that frames the quality value between 0-100.
Catch this exception and if working with a webp file raise a more useful exception.
Disable support for webp.
Use the quality value from the source image (if this is available) in the default case.
Omit the quality parameter unless the user defined it.
Change the default to 75 or another valid value (see below).
On the file formats page, only jpeg, tiff and webp seem to accept quality. Jpeg accepts 0-95 (75 default), tiff is 0-100 (75 default) and webp accepts 0-100 (80 default). This is how I arrived at my default of 75.
The text was updated successfully, but these errors were encountered:
If you leave the default quality set to
-1
When saving a webp image, you will receive the following exception
ValueError: invalid configuration
. This error originates from the webp handling in Pillow here:https://github.com/python-pillow/Pillow/blob/main/src/_webp.c#L673C10-L673C28
Which in turn is calling libwebp's
WebPValidateConfig()
function, which is here:https://github.com/webmproject/libwebp/blob/6a22b6709ce9e8fea5a487b37417f695df89b286/src/enc/config_enc.c#L99
It expects a value between 0 and 100. Therefore
quality=-1
is an invalid value for webp images.I am working around this by defining a default quality of
75
, however, I would expect the default to be usable "out of the box". If you have some guidance on how you would like this fixed I will open a PR. I have a couple ideas:Pillow docs for
Image.save()
say:"The available options are described in the image format documentation for each writer."
On the file formats page, only jpeg, tiff and webp seem to accept
quality
. Jpeg accepts 0-95 (75 default), tiff is 0-100 (75 default) and webp accepts 0-100 (80 default). This is how I arrived at my default of 75.The text was updated successfully, but these errors were encountered: