How to convert image to text using python

Опубликовано: 17 Март 2025
на канале: Kian Brose
73,636
2.7k

In this tutorial you will learn how to convert / turn images into text by using python and the pytesseract ocr module. You will also learn how to automate keyboard functions and drag the mouse so that you can “do something” based on the text you detect.

Pytesseract ocr is a python library that helps with optical character recognition, or “ ocr “ in short. If you are having issues with the ocr library, please try to use python 3.7 64 bit. If you are getting inaccurate results, try to make the image size larger as ocr gets better the larger the image is (don’t overdo it of course)

As usual, the full finished code can be found on the project’s github page:
https://github.com/KianBrose/Python-b...

Convert image to text: 0:25
Keyboard automation: 4:14
Mouse drag: 6:15

Code and links used in video (in order):

Image to text:

https://github.com/UB-Mannheim/tesser...

pip install pytesseract
pip install pillow

import pyautogui
from PIL import Image
from pytesseract import *
pytesseract.tesseract_cmd = r'C:\Users\Antec\AppData\Local\Tesseract-OCR\tesseract.exe'

Keyboard automation:
pip install pywin32
pip install pyautogui
pip install keyboard

import time
import pyautogui
import keyboard
import win32api, win32con

Mouse drag:

import time
import win32api, win32con
time.sleep(2)

win32api.SetCursorPos((500,500))
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(0.1)
win32api.SetCursorPos((500,300))
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)


Hope you enjoyed the video, if it helped please consider subscribing :)
If you have any bugs / errors feel free to join the discord server where you can get near instant help:   / discord  

I will also run polls on the server for future videos, so check it out if you’re interested in staying.

This video is part of a series of botting tutorials where you can learn how to bot / automate daily tasks. The first video can be found here:    • How to make advanced image recognitio...  


Thanks for watching!

#botting #python #automation