mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #5919 from radarhere/duplicate
Remove consecutive duplicates that only differ by their offset
This commit is contained in:
commit
a8f90a3916
BIN
Tests/images/timeout-6646305047838720
Normal file
BIN
Tests/images/timeout-6646305047838720
Normal file
Binary file not shown.
|
@ -3,7 +3,7 @@ from io import BytesIO
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import Image, TiffImagePlugin
|
from PIL import Image, ImageFile, TiffImagePlugin
|
||||||
from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION
|
from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
|
@ -726,6 +726,14 @@ class TestFileTiff:
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
im.load()
|
im.load()
|
||||||
|
|
||||||
|
@pytest.mark.timeout(6)
|
||||||
|
@pytest.mark.filterwarnings("ignore:Truncated File Read")
|
||||||
|
def test_timeout(self):
|
||||||
|
with Image.open("Tests/images/timeout-6646305047838720") as im:
|
||||||
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
||||||
|
im.load()
|
||||||
|
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not is_win32(), reason="Windows only")
|
@pytest.mark.skipif(not is_win32(), reason="Windows only")
|
||||||
class TestFileTiffW32:
|
class TestFileTiffW32:
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
import itertools
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -210,6 +211,13 @@ class ImageFile(Image.Image):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
prefix = b""
|
prefix = b""
|
||||||
|
|
||||||
|
# Remove consecutive duplicates that only differ by their offset
|
||||||
|
self.tile = [
|
||||||
|
list(tiles)[-1]
|
||||||
|
for _, tiles in itertools.groupby(
|
||||||
|
self.tile, lambda tile: (tile[0], tile[1], tile[3])
|
||||||
|
)
|
||||||
|
]
|
||||||
for decoder_name, extents, offset, args in self.tile:
|
for decoder_name, extents, offset, args in self.tile:
|
||||||
decoder = Image._getdecoder(
|
decoder = Image._getdecoder(
|
||||||
self.mode, decoder_name, args, self.decoderconfig
|
self.mode, decoder_name, args, self.decoderconfig
|
||||||
|
|
Loading…
Reference in New Issue
Block a user