Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS with pixel doubling caused ImageGrab Error #118

Closed
backtraxe opened this issue Apr 11, 2022 · 3 comments
Closed

MacOS with pixel doubling caused ImageGrab Error #118

backtraxe opened this issue Apr 11, 2022 · 3 comments
Labels
bug Something isn't working macOS

Comments

@backtraxe
Copy link

In MacOS, turning on pixel doubling will cause a difference between the real resolution and the display resolution, which will affect the screenshots of ImageGrab.

For me, my monitor's real resolution is 3840x2160, after pixel doubling, it becomes 1920x1080, so the use of ImageGrab.grab(bbox=(x1, y1, x2, y2)) caused PIL.UnidentifiedImageError.

To solve the problem,

  1. Check your monitor's real resolution. (For me is 3840x2160)
  2. Check your displayed resolution. (For me is 1920x1080)
import tkinter as tk
root = tk.Tk()
print(root.winfo_screenwidth())
print(root.winfo_screenheight())
root.destroy()
  1. I use ImageGrab.grab() for whole screenshot, then crop it.

gui.py, line 266

factor = 3840 / 1920 # repalced with your real resolution / displayed resolution
img = ImageGrab.grab()
img = img.crop((x1*factor, y1*factor, x2*factor, y2*factor))
@lukas-blecher
Copy link
Owner

seems to be the same issue as in python-pillow/Pillow#6144
Can you check if your Pillow version is 9.1.0 and try again?

@backtraxe
Copy link
Author

seems to be the same issue as in python-pillow/Pillow#6144 Can you check if your Pillow version is 9.1.0 and try again?

My Pillow version is 9.1.0.

@lukas-blecher
Copy link
Owner

lukas-blecher commented Apr 11, 2022

Can you quickly check what happens with version 9.0.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working macOS
Projects
None yet
Development

No branches or pull requests

2 participants