Created
December 15, 2025 15:42
-
-
Save bryanseah234/9895550b7d4e94c7d185ed60716fdadb to your computer and use it in GitHub Desktop.
find-text-code (code to find text in images)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pytesseract | |
| import os | |
| import sys | |
| pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract' | |
| directory =input('Where to find text from?\n') | |
| for file in os.listdir(directory): | |
| filename = os.fsdecode(file) | |
| if filename.endswith(".jpg") or filename.endswith(".JPEG") or filename.endswith(".JPG") or filename.endswith(".jpeg"): | |
| imagepath = os.path.join(directory, filename) | |
| text = pytesseract.image_to_string(imagepath) | |
| if text == '': | |
| pass | |
| else: | |
| os.remove(imagepath) | |
| print(f'Removed {filename} from {directory}') | |
| else: | |
| continue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment