DEV Community

Cover image for Day 5 - 100 days of Coding - Python - Add text into Image
Ganesh Raja
Ganesh Raja

Posted on

1

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

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)

Enter fullscreen mode Exit fullscreen mode

You can check the sample image in header

You can check the full code in my repo automated_python_Scripts

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video

Top comments (0)

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay