Closed noisytoken closed 5 years ago
The error message is bad, and I'll fix that. However, for your use case the problem is that the image is greyscale, which is not a valid image input mode for libwebp. To get around this, add the following line after loading the image:
img = img.convert('RGB')
Fixed error message in https://github.com/anibali/pywebp/commit/98b1afab7da6740eb223bebbb31ea6d52761a6af
I am mostly dealing with png images and on occasions, cwebp dramatically increases the file size. How to optimize such images?
Not sure. Could it be that those images are the greyscale ones? As far as I know, webp does not have a greyscale profile so they would be stored as RGB images, which could result in larger files.
The
save_image()
raisesValueError
on some images. Here is the image and code to reproduce the error.img1
Stack trace: