@@ -91,35 +91,35 @@ def test_pil_support_ref():
9191
9292
9393@pytest .mark .skipif (MISSING_NUMPY or MISSING_PIL , reason = "Needs numpy and pillow" ) # type: ignore
94- def test_recompress_shrink_image_small_returns_unchanged ():
94+ def test_shrink_image_if_needed_small_returns_unchanged ():
9595 """Images at or below the byte threshold are passed through untouched."""
9696 np .random .seed (0 )
9797 small = jpeg_from_numpy (np .random .uniform (0 , 255 , (200 , 200 , 3 )))
9898 assert len (small ) <= MAX_BYTES_IMAGE_SIZE
99- assert recompress_shrink_image (small ) is small
99+ assert shrink_image_if_needed (small ) is small
100100
101101
102102@pytest .mark .skipif (MISSING_NUMPY or MISSING_PIL , reason = "Needs numpy and pillow" ) # type: ignore
103- def test_recompress_shrink_image_oversized_dimensions_get_resized ():
103+ def test_shrink_image_if_needed_oversized_dimensions_get_resized ():
104104 """Images above the byte threshold with longest side > 1024 are downscaled."""
105105 np .random .seed (0 )
106106 # Random noise compresses poorly, so 3000x4000 easily exceeds the 256 KB threshold.
107107 big = jpeg_from_numpy (np .random .uniform (0 , 255 , (3000 , 4000 , 3 )))
108108 assert len (big ) > MAX_BYTES_IMAGE_SIZE
109- out = recompress_shrink_image (big )
109+ out = shrink_image_if_needed (big )
110110 out_img = Image .open (BytesIO (out ))
111111 # 3000x4000 scaled so longest side == 1024 preserves the 3:4 aspect ratio.
112112 assert out_img .size == (1024 , 768 )
113113
114114
115115@pytest .mark .skipif (MISSING_NUMPY or MISSING_PIL , reason = "Needs numpy and pillow" ) # type: ignore
116- def test_recompress_shrink_image_oversized_bytes_only_gets_reencoded ():
116+ def test_shrink_image_if_needed_oversized_bytes_only_gets_reencoded ():
117117 """Images above the byte threshold but with longest side <= 1024 are re-encoded only."""
118118 np .random .seed (0 )
119119 arr = np .random .uniform (0 , 255 , (768 , 1024 , 3 ))
120120 high_q = jpeg_from_numpy (arr , jpeg_quality = 99 )
121121 assert len (high_q ) > MAX_BYTES_IMAGE_SIZE
122- out = recompress_shrink_image (high_q )
122+ out = shrink_image_if_needed (high_q )
123123 out_img = Image .open (BytesIO (out ))
124124 assert out_img .size == (1024 , 768 )
125125 # Bytes changed (proves re-encode happened) and got smaller (Q85 vs Q99).
0 commit comments