2

Currently im using python with the Pillow library

from PIL import ImageGrab

px = ImageGrab.grab().load()
color = px[961, 596]

this works, but its quite slow, im looking for something that can run under ~50ms, i dont need it to be python, any language is fine as long as its fast.

also, im on linux

Narcotix
  • 41
  • 2
  • Does this answer your question? [Fastest way to take a screenshot with python on windows](https://stackoverflow.com/questions/3586046/fastest-way-to-take-a-screenshot-with-python-on-windows) – Aaron Jul 24 '22 at 04:19
  • Why are you not using the `bbox` parameter? – Kelly Bundy Jul 24 '22 at 04:25
  • @KellyBundy , tried it but its only a couple ms faster at 131 ms – Narcotix Jul 24 '22 at 04:53
  • 1
    You can try `pyautogui`, but they may be grabbing the whole screen as well. Which operating system is this? On WIndows, you can make a GDI call to fetch a single pixel. – Tim Roberts Jul 24 '22 at 05:08
  • Can't try it myself but that sounds surprising. How did you call it? – Kelly Bundy Jul 24 '22 at 05:17
  • @KellyBundy ``` px = ImageGrab.grab(bbox=(596, 961, 596, 961), xdisplay=":0").load() ``` im using the "time" shell command to time how long it takes – Narcotix Jul 24 '22 at 05:55
  • @TimRoberts linux, as mentioned in the post – Narcotix Jul 24 '22 at 05:55
  • @Narcotix So you're not measuring how long the grabbing takes but how long starting Python and importing PIL takes? – Kelly Bundy Jul 24 '22 at 06:01
  • @KellyBundy wierd, i tried measuring it within the program with .time() and it says 20 ms, but when using the program there is a 130 ms delay between each fetch – Narcotix Jul 24 '22 at 06:08
  • Kelly asked the right question. Do you mean in a `while True:` loop you only get 8 grabs per second, or do you mean running `python grab.py` as a one-shot you only get 8 grabs per second? – Tim Roberts Jul 24 '22 at 17:59

0 Answers0