Fix screenshot function to save user specified <imageFilename> on macOS#128
Open
addisonlee wants to merge 1 commit intoasweigart:masterfrom
Open
Fix screenshot function to save user specified <imageFilename> on macOS#128addisonlee wants to merge 1 commit intoasweigart:masterfrom
addisonlee wants to merge 1 commit intoasweigart:masterfrom
Conversation
…acOS `screenshot` was only saving files for Pillow versions < 6.2.1. It now saves files for Pillow versions >= 6.2.1 as well. No new tests were added since there was already a (failing) test for this.
screenshot function to save user specified <imageFilename> on m…|
Hello, @asweigart, I am commenting to confirm that this pull request effectively solves the silent screenshot failure on macOS. I was experiencing the exact same issue on my system (macOS 15.6.1) where pyscreeze.screenshot() would run without error but produce no file. I have manually applied this fix, and it resolved the problem perfectly. The change makes the macOS implementation consistent with the Windows and Linux versions by adding the im.save() command. This seems to be a reliable and necessary fix. @addisonlee, Thank you for your work on this project. |
This was referenced Aug 25, 2025
pyautogui.screenshot() fails silently on macOS even with permissions granted
asweigart/pyautogui#933
Closed
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.
Summary
On macOS, the
screenshotfunction was only saving the user specified <imageFileName> for Pillow versions < 6.2.1.It now saves user specified files for Pillow versions >= 6.2.1 as well.
Testing notes
I did not add any tests since
test_pyscreeze.pyalready contained a failingtest_screenshottest.It contained 2 failing assertions. The 1st one (checking the saved file) now passes with this fix. The 2nd one (comparing size to resolution) still fails but it's a separate issue not related to this change.