asweigart / pyscreeze

PyScreeze is a simple, cross-platform screenshot module for Python 2 and 3.
BSD 3-Clause "New" or "Revised" License
194 stars 96 forks source link

locateOnScreen using base64 image instead of file on disk? #59

Open rainwater11 opened 4 years ago

rainwater11 commented 4 years ago

Is there a way to find an image based on base64 string instead of reading the file from disk?

majora2007 commented 4 years ago

If you take a look at how locate works, it has a check for if filename, otherwise it assumes a PIL.Image.

So you can do PIL.Image.open(StringIO(base64.b64decode(b64_string))) to generate an image object from base64 and that should work if you pass it in. I haven't tested with pyautogui myself, but this should work as I've implemented something similar in my program.

https://github.com/asweigart/pyscreeze/blob/master/pyscreeze/__init__.py