Merge pull request #4620 from ElinksFr/fix-gbr-image-loading

Fix repeatedly loading .gbr
This commit is contained in:
Andrew Murray 2020-05-17 11:34:58 +10:00 committed by GitHub
commit ac11fa7d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -15,3 +15,11 @@ 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_multiple_load_operations():
with Image.open("Tests/images/gbr.gbr") as im:
im.load()
im.load()
with Image.open("Tests/images/gbr.png") as target:
assert_image_equal(target, im)

View File

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