loading...
Cover image for Day 5 - 100 days of Coding - Python - Add text into Image

Day 5 - 100 days of Coding - Python - Add text into Image

ganesh profile image Ganesh Raja ・1 min read

100 Days of Code (6 Part Series)

1) Vs-Code Extension - Project Setup and Basic functionalities 2) Vs Code Extension 3 ... 4 3) Day 3 - 100 days of Coding - Vs Code Extension 4) Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file 5) Day 5 - 100 days of Coding - Python - Add text into Image 6) Day 6 - 100 days of Coding - Vs Code Extension - add restart feature

So it's day 5 of 100 days of coding. Today I wanted to try something different. I want to add the day into my cover pic daily. Doing it manually would be boring. So I thought of automating it. So today we are gonna add the Number of the day I am working on into the image using Open CV

Today's Objectives

1) Create a python script that will automatically add the given day's text into image

import cv2
import os

x_and_y = (470, 340)
font_color = (255, 255, 255)
font_scale = 2
font = cv2.FONT_HERSHEY_SIMPLEX
output_folder = './'

date = input("Enter the date to be added ") # Get Date to be added from user
im = cv2.imread('data/100_days_image_template.jpeg', 1)

cv2.putText(im, 'Day {}'.format(date), x_and_y,
            font, font_scale, font_color, 2)
cv2.imwrite(output_folder+date+".jpeg", im)

You can check the sample image in header

You can check the full code in my repo automated_python_Scripts

100 Days of Code (6 Part Series)

1) Vs-Code Extension - Project Setup and Basic functionalities 2) Vs Code Extension 3 ... 4 3) Day 3 - 100 days of Coding - Vs Code Extension 4) Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file 5) Day 5 - 100 days of Coding - Python - Add text into Image 6) Day 6 - 100 days of Coding - Vs Code Extension - add restart feature

Posted on Apr 14 by:

Discussion

markdown guide