DEV Community

Cover image for Batch generate YouTube playlist thumbnails with custom text using Python
Vijay Bhaskar
Vijay Bhaskar

Posted on

Batch generate YouTube playlist thumbnails with custom text using Python

GitHub logo vijjusri14 / posterMark

Batch generate posters with custom text

Batch generate posters with custom text

Useful to generate YouTube playlist thumbnails

Sample

Folder Structure

assets  
│
└─── fonts
│       Satisfy.ttf
│       ShadowIntoLight.ttf
│
└─── images
        poster.png
Enter fullscreen mode Exit fullscreen mode

Place your TrueTypeFonts in the fonts directory and background images in the images directory

Settings

Update settings.json to customize the output

{
    "OutputPath": "out",
    "ImagesPath": "./assets/images/",
    "BackgroundImage": "poster.png",
    "FontsPath": "./assets/fonts/",
    "Title": {
        "Font": "ShadowsIntoLight.ttf",
        "Size": 300,
        "Color": "(254, 27, 28)",
        "Position": "(100, 50)"
    },
    "Subtitle": {
        "Font": "Satisfy.ttf",
        "Size": 150,
        "Color": "(85, 30, 138)",
        "Position": "(100, 500)"
    }
}
Enter fullscreen mode Exit fullscreen mode

You can also change the background image, title and subtitle fonts

The color is represented by (R, G, B) values and position by (X, Y)

The fonts used here are Satisfy and ShadowsIntoLight from Google fonts

Posters

Update fileList.json to specify the titles and subtitles for the posters

{
  "Sample": {
    "Title": "PosterMark",
    "Subtitle": "Batch generate posters with custom text"
  }
}
Enter fullscreen mode Exit fullscreen mode

Key of the each json object will be the file name of the poster. Here in the above example, the file name will be Sample.png

Usage

Install Python3

Clone this repository

Create a virtual environment(venv) in the cloned repository directory and activate the venv

python3 -m venv .\venv
Enter fullscreen mode Exit fullscreen mode

Install pip packages

pip install -r .\requirements.txt
Enter fullscreen mode Exit fullscreen mode

Update settings.json and fileList.json as required

Run python script

python posterMark.py
Enter fullscreen mode Exit fullscreen mode

Top comments (0)