Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

image to text python

from PIL import Image
import pytesseract

image = 'PATH/TO/IMAGE'
text = pytesseract.image_to_string(Image.open(image), lang="eng")
print(text)

# Code From here: https://www.youtube.com/watch?v=kxHp5ng6Rgw
Comment

image to text python

from os import closerange
from PIL import Image
import pytesseract as tess
tess.pytesseract.tessetact_cmd = r'give your PATH TO TESSETACT.EXE'

image = r'complete path to image file'
text = tess.image_to_string(Image.open(image), lang="eng")
print(text)
Comment

text to image python

import Image
import ImageDraw
import ImageFont

def getSize(txt, font):
    testImg = Image.new('RGB', (1, 1))
    testDraw = ImageDraw.Draw(testImg)
    return testDraw.textsize(txt, font)

if __name__ == '__main__':

    fontname = "Arial.ttf"
    fontsize = 11   
    text = "example@gmail.com"
    
    colorText = "black"
    colorOutline = "red"
    colorBackground = "white"


    font = ImageFont.truetype(fontname, fontsize)
    width, height = getSize(text, font)
    img = Image.new('RGB', (width+4, height+4), colorBackground)
    d = ImageDraw.Draw(img)
    d.text((2, height/2), text, fill=colorText, font=font)
    d.rectangle((0, 0, width+3, height+3), outline=colorOutline)
    
    img.save("D:/image.png")
Comment

PREVIOUS NEXT
Code Example
Python :: sqlalchemy create engine SQLite Relative 
Python :: How to obtain Open Weather API date/time from city being fetched? 
Python :: mo.group() separated with spaces instead of commas python 
Python :: Reading from a file way02 
Python :: python insert text in string before certain symbol 
Python :: enregistremen en pythin picklr 
Python :: Python Global variable and Local variable with same name 
Python :: Python Creating a Tuple 
Python :: python deque deep copy 
Python :: Python match.span() 
Python :: python read and write lines in file 
Python :: django q and f 
Python :: comment analyser la différence de pixel entre deux images python 
Python :: python break string to sections 
Python :: put legend in subplot 
Python :: string letters only 
Python :: set layer start and end time arcpy 
Python :: how to use the "import random" in-built model in python 
Python :: auto clicker 
Python :: Odoo Module ACL(Access Controls List) 
Python :: django startapp in a folder,,while inside that folder 
Python :: pd.generate_date 
Python :: frame work in turtle module 
Python :: newton backward interpolation python code 
Python :: Open a web browser in Python 
Python :: visualizing of convolutional kernels using pytorch 
Python :: tkinter radiobutton "bind_all" 
Python :: re.add python 
Python :: is python3 enough for react native 
Python :: how to def a variable in python 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =