'Open webp file with Pillow
On an Anaconda set up, I want to run following simple code:
from PIL import Image
img = Image.open('test.webp')
This works on my Linux machine, but on Windows:
UserWarning: image file could not be identified because WEBP support not installed
warnings.warn(message)
---------------------------------------------------------------------------
UnidentifiedImageError Traceback (most recent call last)
<ipython-input-3-79ee787a81b3> in <module>
----> 1 img = Image.open('test.webp')
~\miniconda3\lib\site-packages\PIL\Image.py in open(fp, mode, formats)
3028 for message in accept_warnings:
3029 warnings.warn(message)
-> 3030 raise UnidentifiedImageError(
3031 "cannot identify image file %r" % (filename if filename else fp)
3032 )
UnidentifiedImageError: cannot identify image file 'test.webp'
I do have the libwebp package installed, and libwebp.dll is present in the Library\bin directory of my Anaconda set up.
Any idea?
Solution 1:[1]
The question is whether Anaconda actually builds Pillow with webp support. Looking on the anaconda website I couldn't determine this.
However, conda-forge does build Pillow with webp support, see here. So you might want to consider using that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roland Smith |
