Skip to content

Instantly share code, notes, and snippets.

@lobster1234
Created November 25, 2024 09:32
Show Gist options
  • Save lobster1234/a6400c807683c9a9051742ee5ca9f9f0 to your computer and use it in GitHub Desktop.
Save lobster1234/a6400c807683c9a9051742ee5ca9f9f0 to your computer and use it in GitHub Desktop.
Script to extract text from an image file, mostly for screenshots
from PIL import Image
from pytesseract import pytesseract
img = Image.open(path_to_file)
text = pytesseract.image_to_string(img)
print(text)
@lobster1234
Copy link
Author

used brew install tesseract to install tesseract on MacOS

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