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 :: pandas change dtype to string 
Python :: Could not find a version that satisfies the requirement psycopg2=2.8 (from pgcli) (from versions: 2.7.5, 2.7.6, 2.7.6.1, 2.7.7) 
Python :: portscan with python 
Python :: pen down python turtle 
Python :: python find index of highest value in list 
Python :: split a path into all subpaths 
Python :: how to get pc name with python 
Python :: install python3.7 ubuntu 20.04 
Python :: export python pandas dataframe as json file 
Python :: pandas remove time from datetime 
Python :: opencv get area of contour 
Python :: how to save a dictionary to excel in python 
Python :: flask if statement 
Python :: seaborn pairplot label rotation 
Python :: python sleep milliseconds 
Python :: python opencv write text on image 
Python :: discord.py presence 
Python :: list files in directory python 
Python :: python float till 2 decimal places 
Python :: is python easier than javascript 
Python :: dollar 
Python :: python discord webhook 
Python :: python flatten dict 
Python :: generate a list of random non repeated numbers python 
Python :: remove None pandas 
Python :: type of type is equal to type 
Python :: convert a dictionary into dataframe python 
Python :: draw circles matplotlib 
Python :: get python version in code 
Python :: django.db.backends.mysql install 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =