fix reading from empty buffer when loading .gbr

This commit is contained in:
Simon Andrieux 2020-05-11 17:38:42 +02:00
parent a28b2ea11c
commit 15ae39674e
2 changed files with 10 additions and 2 deletions

View File

@ -15,3 +15,10 @@ def test_gbr_file():
with Image.open("Tests/images/gbr.gbr") as im:
with Image.open("Tests/images/gbr.png") as target:
assert_image_equal(target, im)
def test_multiples_operation():
with Image.open("Tests/images/gbr.gbr") as im:
rect = (0, 0, 10, 10)
im.crop(rect)
im.crop(rect)

View File

@ -84,8 +84,9 @@ class GbrImageFile(ImageFile.ImageFile):
self._data_size = width * height * color_depth
def load(self):
self.im = Image.core.new(self.mode, self.size)
self.frombytes(self.fp.read(self._data_size))
if not self.im:
self.im = Image.core.new(self.mode, self.size)
self.frombytes(self.fp.read(self._data_size))
#