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 :: how to print values without space in python 
Python :: how to import something in python 
Python :: pandas split cell into multiple columns 
Python :: python background process 
Python :: format number differences in python 
Python :: python check if string is float 
Python :: change folder icon with python 
Python :: how to move the element of an array in python by one step 
Python :: reactstrap example 
Python :: how to delete in python 
Python :: how to use replace in python 
Python :: read csv limit rows python 
Python :: plot circles in matplotlib 
Python :: python save images from directory to list 
Python :: How to take n space separated Integer in a list in python? 
Python :: How determine if a number is even or odd using Modulo Operator 
Python :: tail a log file with python 
Python :: data types in numpy array 
Python :: relative frequency histogram python 
Python :: python monitor directory for files count 
Python :: functions in python programming 
Python :: model coefficients 
Python :: pandas rearrange rows based on datetime index 
Python :: plotly pdf report 
Python :: sorted python 
Python :: model.predict Decision Tree Model 
Python :: python get parent class 
Python :: python cv2 how to update image 
Python :: python remove second occurrence of character in string 
Python :: index of and last index of in python 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =