mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Move jpeg-specific eof-processing to jpeg plugin
This commit is contained in:
parent
add2746ac6
commit
1e9e64c8b0
|
@ -221,7 +221,7 @@ class ImageFile(Image.Image):
|
|||
|
||||
if not s: # truncated jpeg
|
||||
if LOAD_TRUNCATED_IMAGES:
|
||||
s = b"\xFF\xD9" # Pretend file is finished adding EOI marker
|
||||
break
|
||||
else:
|
||||
self.tile = []
|
||||
raise IOError("image file is truncated "
|
||||
|
|
|
@ -353,6 +353,21 @@ class JpegImageFile(ImageFile.ImageFile):
|
|||
else:
|
||||
raise SyntaxError("no marker found")
|
||||
|
||||
def load_read(self, read_bytes):
|
||||
"""
|
||||
internal: read more image data
|
||||
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
|
||||
so libjpeg can finish decoding
|
||||
"""
|
||||
s = self.fp.read(read_bytes)
|
||||
|
||||
if not s and ImageFile.LOAD_TRUNCATED_IMAGES:
|
||||
# Premature EOF.
|
||||
# Pretend file is finished adding EOI marker
|
||||
return b"\xFF\xD9"
|
||||
|
||||
return s
|
||||
|
||||
def draft(self, mode, size):
|
||||
|
||||
if len(self.tile) != 1:
|
||||
|
|
Loading…
Reference in New Issue
Block a user