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
Build a Self-Healing AI Content Agent with Claude Agent SDK
I got tired of the content grind. Write a post, format it for X, reformat for Bluesky, render a video, upload to YouTube, cross-post to Instagram — repeat daily. It was eating 2-3 hours every day. So I built a self-healing AI content agent that does all of it. It runs 24/7 on a Mac…
Run a Claude Agent on a Schedule: Cron Jobs, Persistent Memory, and Error Recovery
Building an AI agent is the easy part. Making it run a Claude agent on a schedule reliably every day without babysitting — that’s where most tutorials stop. I run an autonomous Claude agent called Koda. It executes 15+ scheduled tasks daily: pulling analytics from YouTube, Google Search Console, and Instagram, scanning X for viral…
Automate Your Blog Publishing in 2026: From Draft to Live in One Command
Blog automation saved me 15-20 minutes per post. That’s the manual workflow: write in your editor, open WordPress, paste and reformat, upload a featured image, configure SEO metadata, hit publish. Multiply that by 3-4 posts per week and you’re losing hours to busywork that adds zero value. I built a system that takes a markdown…