Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find out length of a string in pixels python

from PIL import ImageFont

def get_pil_text_size(text, font_size, font_name):
    font = ImageFont.truetype(font_name, font_size)
    size = font.getsize(text)
    return size

get_pil_text_size('Hello world', 12, 'times.ttf')
Comment

PREVIOUS NEXT
Code Example
Python :: reverse order of dataframe rows 
Python :: how to iterate through a pandas dataframe 
Python :: binary search iterative 
Python :: HOW TO CREATE A DATETIME LIST QUICK 
Python :: how to add to beginning of linked list python 
Python :: python json change line 
Python :: python text recognition 
Python :: detect if usb is plugged in python 
Python :: threshold meaning in pandas dropna 
Python :: python all option 
Python :: merge two list of dictionaries python with string 
Python :: how to get index in python 
Python :: The function to be built, amino_acids, must return a list of a tuple and an integer when given a string of mRNA code. 
Python :: python display text in label on new line 
Python :: fonts in python 
Python :: Binary search tree deleting 
Python :: displaying data from this column where value is this python 
Python :: python logging levels 
Python :: numpy sort multidimensional array 
Python :: django pass list of fields to values 
Python :: python derivative of mean squared error 
Python :: counting unique values python 
Python :: argparse parse path 
Python :: cursor python 
Python :: jupyter dataframe print all 
Python :: dbscan python 
Python :: cv2.imwrite path 
Python :: color module python 
Python :: selenium options python path 
Python :: pytest for loop 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =