New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot convert high resolution jpg file to webp #5461
Comments
Could we get a copy of "xxxxx.jpg"? |
I upload a copy at: http://47.74.156.104/89218229_p0.jpg.zip |
Strangely enough, I find that if I specify p2.save(outfile, format='webp', quality=90, optimize=True, progressive=True, method=4) it works. In the next version of Pillow, #5450 will mean that the new default will be 4 - so you will no longer have to add on |
@radarhere Thanks, I will try the method argument first for now. |
Looking at the error that is thrown, it is error code 6 from webp, PARTITION0_OVERFLOW - "partition is bigger than 512k". So it makes sense that a larger image is triggering this. This might just be how webp chooses to behave? I'm not personally in favour of automatically restricting the quality of the image to fit that. The only amends we could do might be to show a clearer error message. |
@ma-tongji to check, are you satisfied with this as a solution for your problem? |
I've created PR #5471 to show the error code - 6 in this case - to the user, so that this would be clearer in future Pillow versions. |
@radarhere This make sense. I also tried to save as webp in my windows 10 computer with mode=4 and it also gave me the xmp error. But if I reduce the quality from 90 to 85, this process will work fine. |
Hi, if I get error 6 when saving webp (tried through method from 0 to 6), what can I do to avoid it? |
I suspect you could reduce the quality when saving. Could you attach a copy of the image? |
well, it's hard to get the exactly the original image, since I'm not using Pillow directly, but getting the error when generating a big xyz plot in A1111 stable diffusion webui according to cwebp's document about -partition_limit, I would suspect that webp not only has a hard coded size limit of 16383 pixels, but also has a soft limit of "Partition0 Size" when:
at the same time I add a detection to change the file format to jpeg or png when total pixels > 16383**2//2 to workaround that. maybe Pillow can expose other cwebp parameters so that it can be further diagnosing? |
If you're not using Pillow directly, how would you plan to address this with whatever advice we might provide? |
Just found this issue that have related errorcode reporting and wonder whether there is something worth discuss. |
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:
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
This is my code:
The text was updated successfully, but these errors were encountered: