I'm trying to get a full screen (1920 x 1080) capture using this code. The saved images are only 1536 x 864 though.
solution: As Mark pointed out below, Windows has scaling which can be changed via Control Panel > Display (turn it all the way down).
from PIL import ImageGrab
import os
import time
def screenGrab():
# snapshot of screen
im = ImageGrab.grab()
# saves in current work directory with name based on time of pic
im.save(os.getcwd() + '\\full_snap__' + str(int(time.time()))
+ '.png', 'PNG')
def main():
screenGrab()
if __name__ == '__main__':
main()
If you have your Display settings set to anything other than the "smaller" (100%) setting which is the default, Windows will tell your applications to render to a smaller area and then magnify the results as it puts it on the desktop. Evidently PIL has a bug caused by this setting, the capture is being cropped to the smaller size rather than the full desktop. The workaround is to be sure that your display settings are set to 100%.
I manage to overcome this issue by adding registry key at
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
add a key with the path to your python.exe and pythonw.exe and in value set HIGHDPIAWARE
like so:
"C:\Users\Greg\Anaconda3\python.exe"="HIGHDPIAWARE" "C:\Users\Greg\Anaconda3\pythonw.exe"="HIGHDPIAWARE"
then everythings should be ok :)
credit to that scipt: Marking Your Python Program as High DPI Aware Seemlessly Windows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With