Skip to content

Instantly share code, notes, and snippets.

@Geekgineer
Created December 4, 2020 15:42
Show Gist options
  • Save Geekgineer/c3106045f09e847751825a099c56ef0e to your computer and use it in GitHub Desktop.
Save Geekgineer/c3106045f09e847751825a099c56ef0e to your computer and use it in GitHub Desktop.
Capture Image from screenshot buffer and encoded to base64 or to numpy array
from io import BytesIO
from base64 import b64encode
import pyscreenshot as ImageGrab
buffer = BytesIO()
im=ImageGrab.grab()
im.save(buffer, format='PNG')
im.close()
b64_str = b64encode(buffer.getvalue())
# Numpy Image
# im=im.convert('RGB')
# im = numpy.array(im)
@Geekgineer
Copy link
Author

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment