Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d127c4

Browse files
committed
Discard the transparency layer (if any) only if the image is completely opaque.
1 parent bb2d5f2 commit 5d127c4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ def calculate_rms(expected_image, actual_image):
373373

374374
def _load_image(path):
375375
img = Image.open(path)
376-
return np.asarray(img if img.mode == "RGBA" else img.convert("RGB"))
376+
if img.mode == "RGBA" and img.getextrema()[3][0] < 255:
377+
return np.asarray(img)
378+
return np.asarray(img.convert("RGB"))
377379

378380

379381
def compare_images(expected, actual, tol, in_decorator=False):

0 commit comments

Comments
 (0)