Skip to content

Commit e16dc53

Browse files
authored
Merge pull request #178 from brianhelba/getdata-deprecated
Remove use of deprecated Pillow function
2 parents ad7522c + 9fb0792 commit e16dc53

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

pixelmatch/contrib/PIL.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ def from_PIL_to_raw_data(pil_img: Image) -> MutableImageSequence:
7979
:param pil_img:
8080
:return:
8181
"""
82-
# getdata() returns ImagingCore which is iterable at runtime
83-
return [
84-
item
85-
for sublist in pil_img.convert("RGBA").getdata() # type: ignore[attr-defined]
86-
for item in sublist
87-
]
82+
return list(pil_img.convert("RGBA").tobytes())
8883

8984

9085
def to_PIL_from_raw_data(

test_pixelmatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def pil_to_flatten_data(img):
1919
"""
2020
Convert data from [(R1, G1, B1, A1), (R2, G2, B2, A2)] to [R1, G1, B1, A1, R2, G2, B2, A2]
2121
"""
22-
return [x for p in img.convert("RGBA").getdata() for x in p]
22+
return list(img.convert("RGBA").tobytes())
2323

2424

2525
testdata = [

0 commit comments

Comments
 (0)