Skip to content

Commit 15ae396

Browse files
committed
fix reading from empty buffer when loading .gbr
1 parent a28b2ea commit 15ae396

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Tests/test_file_gbr.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ 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_multiples_operation():
21+
with Image.open("Tests/images/gbr.gbr") as im:
22+
rect = (0, 0, 10, 10)
23+
im.crop(rect)
24+
im.crop(rect)

src/PIL/GbrImagePlugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ def _open(self):
8484
self._data_size = width * height * color_depth
8585

8686
def load(self):
87-
self.im = Image.core.new(self.mode, self.size)
88-
self.frombytes(self.fp.read(self._data_size))
87+
if not self.im:
88+
self.im = Image.core.new(self.mode, self.size)
89+
self.frombytes(self.fp.read(self._data_size))
8990

9091

9192
#

0 commit comments

Comments
 (0)