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

txt to image python

import aspose.words as aw

doc = aw.Document(Input.txt)
          
for page in range(0, doc.page_count):
    extractedPage = doc.extract_pages(page, 1)
    extractedPage.save(f"Output_{page + 1}.jpg")
Comment

PREVIOUS NEXT
Code Example
Python :: python destructure object 
Python :: python - How to execute a program or call a system command? 
Python :: scrape sitemap 
Python :: pandas read csv specify column dtype 
Python :: text color python tkinter 
Python :: extract address from text python 
Python :: python warnings as error 
Python :: creating numpy array using empty 
Python :: seaborn histplot python 
Python :: pd.merge duplicate columns remove 
Python :: Math Module log10() Function in python 
Python :: sklean tfidf 
Python :: nibabel image 
Python :: python newline 
Python :: assert in python 
Python :: selenium delete cookies python 
Python :: python if index not out of range 
Python :: Using Python-docx to update cell content of a table 
Python :: usign signal files django 
Python :: cmake python interpreter 
Python :: how to list gym envirolments 
Python :: resize qpushbutton pyqt 
Python :: An example of how to associate a color to each bar and plot a color bar 
Python :: what is not equals in python 
Python :: append two dfs 
Python :: tensorflow io check file exist 
Python :: python nearly equal 
Python :: call python from bash shell 
Python :: pandas and operator 
Python :: télécharger librairie avec pip 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =