Skip to content

Cannot convert high resolution jpg file to webp #5461

Description

@ma-tongji

What did you do?

I read in a high resolution jpg image, and convert it to webp format.

What did you expect to happen?

I expected to get a image file with webp format

What actually happened?

I have a image with resolution 4500*6500 and when I direct save this image as webp format, Pillow gives me the error:

Traceback (most recent call last):
  File "/Users/martin/software/miniconda3/envs/py36/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/Users/martin/software/miniconda3/envs/py36/lib/python3.6/site-packages/PIL/Image.py", line 2172, in save
    save_handler(self, fp, filename)
  File "/Users/martin/software/miniconda3/envs/py36/lib/python3.6/site-packages/PIL/WebPImagePlugin.py", line 337, in _save
    xmp,
ValueError: encoding error

I also tried to crop this image to 4500*4500 and save it to webp format. And I get the same "ValueError: encoding error" error.

I tried to crop this image to 4000*4000 and save it to webp format. This time, there's no error and I get the result webp file.

What are your OS, Python and Pillow versions?

OS: Mac OS X El Capitan (10.11.6)
Python: 3.6.4
Pillow: 8.2.0

features.version('webp') returns '1.2.0'

This is my code:

from PIL import Image as PILimage

infile = 'tests/xxxxx.jpg'
outfile = 'tests/webp.webp'

p = PILimage.open(infile)
p2 = p.crop((0,0, 4300, 4300))
p2.save(outfile, format='webp', quality=90, optimize=True, progressive=True)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions