Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add text to jpg python

#first install Library
!pip install pillow

#import as so
from PIL import Image, ImageFont, ImageDraw

#Code
#save image to folder or get the file path
a_image = Image.open('image that you want to edit.jpg') 

#download the font you want and save to the same folder
a_font = ImageFont.truetype('Choice_of_Font.ttf',size=60) 

text = 'Type the text you would like to input'

#convert image to edit
a = ImageDraw.Draw(a_image)

# First Argument is the positioning (vertical,horizontal)
# Third Argumnent is the font color in RHB use color picker to get 
# the color of choice
a.text((420,390),text,(145,116,36),font=a_font)

#save it
a_image.save('image.jpg')

#open the image
a_image.show()
 
PREVIOUS NEXT
Tagged: #add #text #jpg #python
ADD COMMENT
Topic
Name
2+7 =