Skip to content

Commit 98abd62

Browse files
authored
Merge pull request #6186 from radarhere/thumbnail_load
2 parents f1aeb5e + 910a29f commit 98abd62

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

Tests/test_image_thumbnail.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ def test_no_resize():
8888
assert im.size == (64, 64)
8989

9090

91+
def test_load_first():
92+
# load() may change the size of the image
93+
# Test that thumbnail() is calling it before performing size calculations
94+
with Image.open("Tests/images/g4_orientation_5.tif") as im:
95+
im.thumbnail((64, 64))
96+
assert im.size == (64, 10)
97+
98+
9199
# valgrind test is failing with memory allocated in libjpeg
92100
@pytest.mark.valgrind_known_error(reason="Known Failing")
93101
def test_DCT_scaling_edges():
@@ -130,4 +138,4 @@ def test_reducing_gap_for_DCT_scaling():
130138
with Image.open("Tests/images/hopper.jpg") as im:
131139
im.thumbnail((18, 18), Image.Resampling.BICUBIC, reducing_gap=3.0)
132140

133-
assert_image_equal(ref, im)
141+
assert_image_similar(ref, im, 1.4)

src/PIL/Image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,7 @@ def thumbnail(self, size, resample=Resampling.BICUBIC, reducing_gap=2.0):
24482448
:returns: None
24492449
"""
24502450

2451+
self.load()
24512452
x, y = map(math.floor, size)
24522453
if x >= self.width and y >= self.height:
24532454
return

0 commit comments

Comments
 (0)