You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In open(), preinit() only initialize popular formats, _open_core() will raise if the given formats have not been initialized. The init() failback become unreachable.
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
exceptBaseException:
ifexclusive_fp:
fp.close()
raise
returnNone
im=_open_core(fp, filename, prefix, formats)
ifimisNone:
ifinit():
im=_open_core(fp, filename, prefix, formats)
What did you do?
from __future__ importannotationsfromPILimportImagedefmain():
withopen('any.webp', 'rb') asf:
try:
im=Image.open(f, formats=('WEBP',))
exceptException:
print(Image.ID) # No WEBP in the listraiseelse:
print(im.size)
if__name__=='__main__':
main()
What did you expect to happen?
Output the size
(640, 480)
What actually happened?
['BMP', 'DIB', 'GIF', 'TIFF', 'JPEG', 'PPM', 'PNG']Traceback (most recent call last): File "pil_debug.py", line 18, in <module> main() File "pil_debug.py", line 9, in main im = Image.open(f, formats=('WEBP',)) File "lib\site-packages\PIL\Image.py", line 2929, in open im = _open_core(fp, filename, prefix, formats) File "lib\site-packages\PIL\Image.py", line 2909, in _open_core factory, accept = OPEN[i]KeyError: 'WEBP'
What are your OS, Python and Pillow versions?
OS: Windows 10
Python: 3.8
Pillow: 8.0.1
The text was updated successfully, but these errors were encountered:
You can import the WebP plugin explicitly to make sure it is loaded:
fromPILimportImage, WebPImagePluginim=Image.open("Downloads/1.webp", formats=("WEBP",))
# im = <PIL.WebPImagePlugin.WebPImageFile image mode=RGB size=550x368 at 0x233A9546508>
radarhere
changed the title
Unpopular formats argument of PIL.Image.open cause exceptions.
Unpopular formats argument of PIL.Image.open cause exceptions
Nov 11, 2020
In
open()
,preinit()
only initialize popular formats,_open_core()
will raise if the given formats have not been initialized. Theinit()
failback become unreachable.Pillow/src/PIL/Image.py
Lines 2901 to 2934 in 2d6e51e
What did you do?
What did you expect to happen?
Output the size
(640, 480)
What actually happened?
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: