Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Apr 17, 2023

Resolves #7096 by documenting that Image.open() seeks to the start of file objects before reading.

Pillow/src/PIL/Image.py

Lines 3202 to 3225 in aec7a8d

try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot parse inline stream images, because open() always seeks 0

2 participants