Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Created June 11, 2024 13:05
Show Gist options
  • Save sebastianrothbucher/9be7d59fe64693e063069f705571c145 to your computer and use it in GitHub Desktop.
Save sebastianrothbucher/9be7d59fe64693e063069f705571c145 to your computer and use it in GitHub Desktop.
img2txt - clipboard image to clipboard text
#!/bin/zsh
/opt/homebrew/bin/python3 /Users/s.rothbucher/tools/ocr/main.py | pbcopy
import pytesseract
from PIL import Image, ImageGrab
im = ImageGrab.grabclipboard()
#im.save('somefile.png','PNG')
# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'/opt/homebrew/bin/tesseract'
# Simple image to string
print(pytesseract.image_to_string(im))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment