Skip to content

Instantly share code, notes, and snippets.

@bryanseah234
Created December 15, 2025 15:42
Show Gist options
  • Select an option

  • Save bryanseah234/9895550b7d4e94c7d185ed60716fdadb to your computer and use it in GitHub Desktop.

Select an option

Save bryanseah234/9895550b7d4e94c7d185ed60716fdadb to your computer and use it in GitHub Desktop.
find-text-code (code to find text in images)
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