Automate Blog Image Creation Using Python
Creating a featured image for every blog post used to be the most tedious part of publishing for me. I wanted consistent, branded visuals, but manually designing them in Canva, copying over titles, tweaking layouts, and exporting each one quickly became a chore. So I automated the entire process. Now I generate 1200×628px featured…

Creating a featured image for every blog post used to be the most tedious part of publishing for me. I wanted consistent, branded visuals, but manually designing them in Canva, copying over titles, tweaking layouts, and exporting each one quickly became a chore.
So I automated the entire process.
Now I generate 1200×628px featured images using a Python script in seconds, complete with a clean background, styled title, category label, and domain name.
I created the background images in Canva using a free account and added my domain name at the bottom for branding.

Why Automate Featured Images?
- Keeps my posts visually consistent
- Saves tons of time: 5+ images in seconds
- Looks polished on my homepage and in social previews
- Lets me focus on content, not design fiddling
Tools I Use
- Python 3 (preinstalled on macOS/Linux)
- Pillow (Python Imaging Library)
- DejaVuSans-Bold.ttf font
- Backgrounds (one per category, stored as PNGs)
- A CSV file with blog post titles and categories
My Python Script
The script reads a CSV file of blog titles and categories, selects the matching background, adds a semi-transparent dark overlay, then draws a category label and centers the title text with a subtle shadow for better readability.
Here’s a trimmed version of the script:
from PIL import Image, ImageDraw, ImageFont
import csv, os
# --- Config ---
WIDTH, HEIGHT = 1200, 628
FONT_PATH = "fonts/DejaVuSans-Bold.ttf"
FONT_SIZE = 50
SMALL_FONT_SIZE = 24
TEXT_COLOR = "white"
SHADOW_COLOR = "black"
OUTPUT_DIR = "generated-images"
BACKGROUND_DIR = "backgrounds"
# --- Setup ---
os.makedirs(OUTPUT_DIR, exist_ok=True)
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
small_font = ImageFont.truetype(FONT_PATH, SMALL_FONT_SIZE)
# --- Process CSV ---
with open("titles.csv", newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
title = row.get("title", "").strip()
category = row.get("category", "").strip()
if not title or not category:
continue
# ... image generation logic goes hereYou can view the full script on GitHub.
How It Works
- Looks up a background image per category
- Applies a semi-transparent dark overlay
- Adds a category label top-left
- Wraps the title text and centers it
- Exports a PNG with a clean filename
CSV Example
title,category
Automate Blog Image Creation Using Python,Automation
Hardening Azure VM SSH Access,Cybersecurity
Deploying Web Apps with Bicep,Azure Cloud
Running Plex in Proxmox,Homelab
Building an IaC Lab,IaC
Enable Sensitivity Labels in Outlook,Microsoft 365To generate an image, make sure each row in the CSV has a populated title. The script skips empty titles.
Then, run the following:
cd lab/python/blog-image-generator
python3 generate_images.pyIf it was successful you will see something like this:
✅ Created: generated-images/automate-blog-image-creation-using-python.pngYou’ll find the generated image inside the generated-images/ folder.
It should look like this:

Final Thoughts
This little tool saves me a ton of time, keeps my blog visually consistent, and lets me focus on writing instead of fiddling with design.
Happy automating!
Found this helpful? Check out more tech tutorials or follow me on GitHub, where I share homelab setups, automation tools, and real-world projects from my day-to-day work as an IT consultant.
Related
Automatiser bilagsføring med Fiken API og Claude Code
Jeg videresendte kvitteringer til Fiken-inboksen og lot dem ligge. Så satt jeg en kveld i måneden og førte dem manuelt: finn leverandøren, velg konto, velg MVA-kode, last opp PDF-en. Fire klikk, tretten ganger. Så skrev jeg en Claude-skill som gjør det via Fiken API-et.
Build a Self-Healing AI Content Agent with Claude Agent SDK
Write a post, format it for X, reformat for Bluesky, render a video, upload to YouTube, cross-post to Instagram. Repeat daily. That was 2-3 hours of my day, so I built a self-healing AI content agent that does all of it. It runs 24/7 on a Mac…
Automate Your Blog Publishing in 2026: From Draft to Live in One Command
Blog automation saved me 15-20 minutes per post. The manual version went like this: write in your editor, open WordPress, paste and reformat, upload a featured image, configure SEO metadata, hit publish. Three or four posts a week adds up to hours of clicking. So I built a system that takes a markdown…