Remove use of deprecated Pillow function#178
Merged
whtsky merged 1 commit intowhtsky:masterfrom Mar 1, 2026
Merged
Conversation
Fixes whtsky#170 by removing use of `PIL.Image.getdata()`. Rather than using the suggested replacement of `get_flattened_data` which would, require checking the version of Pillow, this uses `PIL.Image.tobytes()`, which is available on all versions of Pillow. `.tobytes` is also significantly faster, as it doesn't require Python list iteration. Since the image is explicitly converted to "RGBA" format, the bytes representation is just a linear list of the pixel values anyway.
|
Contributor
Author
|
@whtsky Please take a look. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #178 +/- ##
=======================================
Coverage 97.95% 97.95%
=======================================
Files 5 5
Lines 147 147
=======================================
Hits 144 144
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Owner
|
Looks good. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #170 by removing use of
PIL.Image.getdata().Rather than using the suggested replacement of
get_flattened_datawhich would, require checking the version of Pillow, this usesPIL.Image.tobytes(), which is available on all versions of Pillow..tobytesis also significantly faster, as it doesn't require Python list iteration. Since the image is explicitly converted to"RGBA"format, the bytes representation is just a linear list of the pixel values anyway.