Skip to content

Commit ac11fa7

Browse files
authored
Merge pull request #4620 from ElinksFr/fix-gbr-image-loading
Fix repeatedly loading .gbr
2 parents bc1dc14 + 7579183 commit ac11fa7

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Tests/test_file_gbr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ def test_gbr_file():
1515
with Image.open("Tests/images/gbr.gbr") as im:
1616
with Image.open("Tests/images/gbr.png") as target:
1717
assert_image_equal(target, im)
18+
19+
20+
def test_multiple_load_operations():
21+
with Image.open("Tests/images/gbr.gbr") as im:
22+
im.load()
23+
im.load()
24+
with Image.open("Tests/images/gbr.png") as target:
25+
assert_image_equal(target, im)

src/PIL/GbrImagePlugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def _open(self):
8484
self._data_size = width * height * color_depth
8585

8686
def load(self):
87+
if self.im:
88+
# Already loaded
89+
return
90+
8791
self.im = Image.core.new(self.mode, self.size)
8892
self.frombytes(self.fp.read(self._data_size))
8993

0 commit comments

Comments
 (0)