What did you do?
Add the method argument (as documented in the handbook) with 0 as value to the Image.save() function with webp as format.
What did you expect to happen?
Pillow/WebP encoding the image with that method.
What actually happened?
The image always got encoded with the default method.
What are your OS, Python and Pillow versions?
- OS: Debian testing (bullseye)
- Python: 3.7.4
- Pillow: 6.1.0 (from pypi)
Used image: https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/512px-Python-logo-notext.svg.png (as image.png)
from PIL import Image
from io import BytesIO
image = Image.open('image.png')
buffer = BytesIO()
image.save(buffer, format='webp', method=0)
print(buffer.getbuffer().nbytes) # 9212
buffer = BytesIO()
image.save(buffer, format='webp', method=6)
print(buffer.getbuffer().nbytes) # 9212
Both of these have the exact same size, which should not be the case given the different method.
Example of different sizes (encoding with cwebp tool):
$ cwebp -m 0 image.png 2>&1 | grep Output
Output: 11396 bytes Y-U-V-All-PSNR 52.79 45.11 45.20 48.64 dB
$ cwebp -m 6 image.png 2>&1 | grep Output
Output: 8408 bytes Y-U-V-All-PSNR 53.12 44.73 44.82 48.43 dB
Encoding as animation, however, uses the set method for encoding, as you can see from the different sizes:
# (continuation from above code snippet)
buffer = BytesIO()
image.save(buffer, format='webp', save_all=True, append_images=[image], method=0)
print(buffer.getbuffer().nbytes) # 12310
buffer = BytesIO()
image.save(buffer, format='webp', save_all=True, append_images=[image], method=6)
print(buffer.getbuffer().nbytes) # 9220
This pull request might be related: #1263
What did you do?
Add the
methodargument (as documented in the handbook) with0as value to theImage.save()function with webp as format.What did you expect to happen?
Pillow/WebP encoding the image with that method.
What actually happened?
The image always got encoded with the default method.
What are your OS, Python and Pillow versions?
Used image: https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/512px-Python-logo-notext.svg.png (as
image.png)Both of these have the exact same size, which should not be the case given the different method.
Example of different sizes (encoding with
cwebptool):Encoding as animation, however, uses the set method for encoding, as you can see from the different sizes:
This pull request might be related: #1263