mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-09 14:54:46 +03:00
Reduce duplicate code in Image open
This commit is contained in:
parent
926a08cdb3
commit
53a966d80f
15
PIL/Image.py
15
PIL/Image.py
|
@ -2299,19 +2299,8 @@ def open(fp, mode="r"):
|
|||
|
||||
preinit()
|
||||
|
||||
for i in ID:
|
||||
try:
|
||||
factory, accept = OPEN[i]
|
||||
if not accept or accept(prefix):
|
||||
fp.seek(0)
|
||||
im = factory(fp, filename)
|
||||
_decompression_bomb_check(im.size)
|
||||
return im
|
||||
except (SyntaxError, IndexError, TypeError, struct.error):
|
||||
logger.debug("", exc_info=True)
|
||||
|
||||
if init():
|
||||
|
||||
for i in range(0, 2):
|
||||
if i == 0 or init():
|
||||
for i in ID:
|
||||
try:
|
||||
factory, accept = OPEN[i]
|
||||
|
|
Loading…
Reference in New Issue
Block a user