AI-powered YouTube thumbnail generator with Chinese/English support and intelligent text processing
Project description
YouTube Thumbnail Generator v2.1
Professional YouTube thumbnail automatic generation tool with intelligent Chinese/English text layout, logo, and precise image control with dynamic adaptation.
Author: Leo Wang (https://leowang.net)
๐ Available on PyPI: https://pypi.org/project/youtube-thumbnail-generator/
๐ GitHub Repository: https://github.com/preangelleo/youtube-thumbnail-generator
๐ Core Features
- โ Intelligent Chinese/English System: PNG overlay technology, perfect Chinese/English text mixing
- โ Smart Line-breaking Algorithm: Chinese 9 character limits, English 3-line truncation
- โ Font Differentiation Optimization: Chinese fonts 30% larger for optimal readability
- โ Professional Visual Effects: Triangle transition integrated into images, text always on top layer
- โ Intelligent Image Processing: Auto square conversion + 900x900 filling
- โ Multi-endpoint API Support: Flask RESTful API + Chapter functionality
- โ Smart Font Selection: Chinese PingFang/Founder, English Lexend Bold
- โ Three Theme Modes: Dark (black bg), Light (white bg), Custom (user template)
- โ Full Color Customization: Title color, author color, triangle toggle - all parameterized
- โ Dynamic Font Scaling: Auto font size adjustment based on text length (1-17 characters)
๐จ Three Theme Modes
Canvas Size: 1600x900 pixels
๐ Dark Theme - Professional Black Background
Perfect for: Tech content, gaming, serious topics
Features: Black background + White bold text + Black triangle overlay + Professional contrast
Chinese Sample (10 characters - optimal length)
English Sample (7 words - optimal length)
๐ Light Theme - Clean White Background
Perfect for: Educational content, lifestyle, bright topics
Features: White background + Black bold text + White triangle overlay + Clean minimalist look
Chinese Sample (10 characters - optimal length)
English Sample (7 words - optimal length)
๐ Custom Theme - Your Own Background
Perfect for: Brand content, creative projects, unique aesthetics
Features: Custom 1600x900 background + Customizable text colors + No triangle overlay + Full creative control
Chinese Sample (10 characters - optimal length)
English Sample (7 words - optimal length)
๐ก Optimal Length Recommendations
๐ฏ Best Results Guidelines
For the most professional and visually appealing thumbnails:
๐จ๐ณ Chinese Titles
Optimal Length: 10-12 characters
- 10 characters: Perfect balance, excellent readability
- 12 characters: Maximum recommended, maintains clarity
- Examples: "AIๆๆฏๆๅๆ็จ" (8 chars) โ "ๅฎๆดAIๆๆฏๆๅๆ็จ็ณป็ป" (12 chars) โ
๐บ๐ธ English Titles
Optimal Length: 7 words
- 7 words: Perfect for 3-line layout without truncation
- Example: "Complete AI Technology Guide Tutorial Series Episode" (7 words) โ
- Note: Longer titles may be truncated with ellipsis (...)
๐ฆ Supported Parameters
Required Parameters
- title - Main title text (required)
Optional Parameters
- author - Author name (optional, auto-capitalized)
- logo_path - Logo file path (optional)
- right_image_path - Right-side image path (optional)
- theme - Theme mode: "dark", "light", "custom" (default: "dark")
- custom_template - Custom background path for custom theme (required when theme="custom")
- title_color - Title text color in hex format (e.g., "#FFFFFF")
- author_color - Author text color in hex format (e.g., "#CCCCCC")
- enable_triangle - Enable/disable triangle overlay (boolean)
Theme Defaults
- Dark Theme: Black bg + White text (#FFFFFF) + Light gray author (#CCCCCC) + Black triangle
- Light Theme: White bg + Black text (#000000) + Dark gray author (#666666) + White triangle
- Custom Theme: User background + White text (#FFFFFF) + Light gray author (#CCCCCC) + No triangle
๐ง Intelligent Text System
Core Technology: PNG Overlay + Triangle Integration
Instead of drawing text directly on template:
- Independent Rendering: Generate transparent PNG text images first
- Smart Adjustment: Dynamically adjust PNG size based on text length
- Triangle Integration: Paste triangle to right-side image first, then paste combined image to template
- Text Overlay: PNG text pasted last, ensuring it's always on the top layer
Chinese/English Differentiated Processing
Chinese Optimization
- Font Enlargement: 30% larger than English (54px vs 42px title)
- Smart Line-breaking:
- Title: Break after 9 characters, divide by 2, odd characters go to second line
- Line Spacing: Title 16px
English Processing
- Space-based Line-breaking: Natural word boundary wrapping
- 3-line Limit: Title max 3 lines, auto-truncate with ellipsis
- Standard Font: Lexend Bold
- Standard Line Spacing: 8px
๐ Input Parameter Details
Required Parameters
title (str) - Main title
title="The Ultimate Complete Guide to Advanced AI Technology"
- Smart Line-breaking: Auto-calculate optimal line-break positions
- Dynamic Height: Adjust PNG height based on line count (55px/line + line spacing)
- Dynamic Font Scaling: Auto font size based on character count (1-17 chars)
- Effects: Clean bold font with theme-based colors
- Position: Starting at (55, 330), dynamically centered
Optional Parameters
author (str) - Author name
author="Leo Wang" # Auto-converts to "LEO WANG"
- Format: Auto-convert to uppercase
- Position: Fixed bottom (55, 800)
- Font: 36px Lexend Bold, theme-based color
logo_path (str) - Logo file path
logo_path="logos/your_logo.png"
- Position: Top-left corner (50, 50), left margin = top margin
- Area: 240x150 pixels, auto aspect ratio scaling
- Format: Supports PNG/JPG, auto-handle transparency
right_image_path (str) - Right-side image path
right_image_path="assets/your_image.jpg"
- Smart Cropping: Auto-convert to square (center crop)
- Fill Method: Scale to 900x900 pixels to fill right side
- Position: Right area starting at (700, 0)
Theme & Color Parameters
theme (str) - Theme mode: "dark", "light", "custom"
theme="dark" # Default: Black bg + white text + black triangle
theme="light" # White bg + black text + white triangle
theme="custom" # User-provided template + custom colors
custom_template (str) - Custom template path (required for custom theme)
custom_template="path/to/your_template.png" # Must be 1600x900 PNG
title_color (str) - Title text color in hex format
title_color="#FFFFFF" # White (dark theme default)
title_color="#000000" # Black (light theme default)
title_color="#FF0000" # Red (custom example)
author_color (str) - Author text color in hex format
author_color="#CCCCCC" # Light gray (dark theme default)
author_color="#666666" # Dark gray (light theme default)
author_color="#0000FF" # Blue (custom example)
enable_triangle (bool) - Enable/disable triangle overlay
enable_triangle=True # Default for dark/light themes
enable_triangle=False # Default for custom theme
๐ฆ Installation
The package is officially available on PyPI and can be installed worldwide:
Quick Install (Recommended)
pip install youtube-thumbnail-generator
With API Service Support
pip install "youtube-thumbnail-generator[api]"
Alternative Installation Methods
| Method | Command | Use Case |
|---|---|---|
| PyPI (Stable) | pip install youtube-thumbnail-generator |
Production use, stable releases |
| PyPI with API | pip install "youtube-thumbnail-generator[api]" |
Include Flask API dependencies |
| GitHub (Latest) | pip install git+https://github.com/preangelleo/youtube-thumbnail-generator.git |
Latest development features |
| Development | git clone ... && pip install -e . |
Local development and testing |
Package Information
- PyPI Page: https://pypi.org/project/youtube-thumbnail-generator/
- Current Version: 2.2.0
- License: MIT
- Python Support: 3.7+
- Dependencies: Pillow (required), Flask+CORS (optional for API)
๐ฆ What's Included Automatically
When you install via PyPI or GitHub, you get everything you need:
- โ All Templates: Dark, Light, and Custom background templates
- โ Triangle Assets: Black and white triangle overlays
- โ Professional Template: 1600x900 high-quality base template
- โ Font Assets: Chinese/English optimized fonts
- โ Sample Assets: Testing logo and image files
No additional downloads needed - start generating thumbnails immediately after installation!
๐ Usage Methods
1. Use as Python Library
Dark Theme (Default)
from youtube_thumbnail_generator import FinalThumbnailGenerator
# Initialize generator
generator = FinalThumbnailGenerator("templates/professional_template.jpg")
# Generate Dark theme thumbnail (recommended: 10-12 Chinese chars or 7 English words)
result = generator.generate_final_thumbnail(
title="Complete AI Technology Guide", # 5 words - will be enlarged
author="Leo Wang",
logo_path="logos/your_logo.png",
right_image_path="assets/your_image.jpg",
output_path="outputs/dark_theme.jpg",
theme="dark" # Default theme
)
Light Theme
# Generate Light theme thumbnail
result = generator.generate_final_thumbnail(
title="AIๆๆฏๆๅๅฎๆดๆ็จ", # 10 Chinese characters - optimal
author="Leo Wang",
logo_path="logos/your_logo.png",
right_image_path="assets/your_image.jpg",
output_path="outputs/light_theme.jpg",
theme="light",
title_color="#000000", # Black text for white background
author_color="#666666" # Dark gray author
)
Custom Theme
# Generate Custom theme with your own background
result = generator.generate_final_thumbnail(
title="Custom Background Demo", # 4 words - will be enlarged
author="Your Name",
logo_path="logos/your_logo.png",
right_image_path=None, # No right image needed
output_path="outputs/custom_theme.jpg",
theme="custom",
custom_template="your_background_1600x900.png", # Your custom background
title_color="#FFFFFF", # White text
author_color="#CCCCCC", # Light gray author
enable_triangle=False # No triangle overlay
)
2. Command Line API Service
Launch API directly after installation:
# Start API service directly
youtube-thumbnail-api
# Or use Python module method
python -m youtube_thumbnail_generator.api_server
3. Use in Other Python Projects
# In your Python projects
from youtube_thumbnail_generator import FinalThumbnailGenerator, create_text_png
# Quick thumbnail generation
generator = FinalThumbnailGenerator("path/to/your/template.jpg")
result = generator.generate_final_thumbnail(
title="Your Video Title",
output_path="output/thumbnail.jpg"
)
# Or generate text PNG only
success, text_img, height = create_text_png(
text="Test Text",
width=600,
height=200,
language="chinese"
)
4. API Service Calls
Generate Thumbnail
curl -X POST http://localhost:5002/api/generate/enhanced \
-H "Content-Type: application/json" \
-d '{
"title": "Amazing Tech Reviews 2025",
"author": "Leo Wang",
"logo_path": "logos/animagent_logo.png",
"right_image_path": "assets/testing_image.jpeg"
}'
Response Example
{
"task_id": "abc123-def456-ghi789",
"status": "processing",
"message": "Thumbnail generation task started"
}
Check Task Status
curl http://localhost:5002/api/status/abc123-def456-ghi789
Download Result
curl -O http://localhost:5002/api/download/final_test.jpg
3. Python API Client Example
import requests
import time
import json
def generate_thumbnail_api(title, author=None, logo_path=None, image_path=None):
"""Generate thumbnail using API"""
# 1. Send generation request
response = requests.post('http://localhost:5002/api/generate/enhanced',
headers={'Content-Type': 'application/json'},
data=json.dumps({
"title": title,
"author": author,
"logo_path": logo_path,
"right_image_path": image_path
})
)
task_data = response.json()
task_id = task_data['task_id']
print(f"Task created: {task_id}")
# 2. Poll status until complete
while True:
status_response = requests.get(f'http://localhost:5002/api/status/{task_id}')
status_data = status_response.json()
print(f"Status: {status_data['status']}")
if status_data['status'] == 'completed':
print(f"Generation complete! Download: {status_data['download_url']}")
return status_data['download_url']
elif status_data['status'] == 'failed':
print(f"Generation failed: {status_data['error']}")
return None
time.sleep(1)
# Usage example
download_url = generate_thumbnail_api(
title="My Amazing YouTube Video Title That Is Really Long",
author="Your Name",
logo_path="logos/my_logo.png",
image_path="assets/thumbnail_image.jpg"
)
๐ฏ Complete API Endpoint Guide
Thumbnail Generation
POST /api/generate/enhanced
Request Body:
{
"title": "Required - Main title text",
"author": "Optional - Author name",
"logo_path": "Optional - Logo file path",
"right_image_path": "Optional - Right-side image path"
}
Chapter Image Generation
POST /api/generate/chapter
Request Body:
{
"text": "Required - Text to display",
"language": "Optional - english/chinese",
"font_size": "Optional - Font size",
"width": "Optional - Image width, default 1600",
"height": "Optional - Image height, default 900"
}
Other Endpoints
GET /api/status/<task_id>- Check task statusGET /api/download/<filename>- Download generated fileGET /api/health- Health checkGET /api/templates- Get available templatesGET /api/assets- Get resource list
๐ Smart Layout Examples
Short Title Effect
Title: "Tech News 2025"
โ 1 line, centered layout, clean appearance
Long Title Effect
Title: "The Ultimate Complete Guide to Advanced AI Technology..."
โ Multiple lines with smart line-breaking
Auto-adjust positions for perfect fit
Overlong Content Handling
Title exceeds 3 lines โ Auto-truncate with ellipsis
Ensure stable layout, prevent content overflow
๐ง Advanced Configuration
File Path Rules
- Relative Paths: Relative to project root directory
- Logo Directory:
logos/- Store all logo files - Assets Directory:
assets/- Store background images - Output Directory:
outputs/- Generated results storage - Template Directory:
templates/- Template file storage
Supported Image Formats
- Input: PNG, JPG, JPEG (supports transparency)
- Output: JPG (high quality, 95% quality)
- Processing: Auto color mode conversion
Font Priority
English Fonts:
1. Helvetica (Mac system)
2. Lexend Bold (if installed)
3. Ubuntu Bold (Linux)
4. System default font
Chinese Fonts:
1. Noto Sans CJK Bold
2. Source Han Sans
3. WenQuanYi fonts
๐ Project Structure
youtube_thumbnail_generator/
โโโ youtube_thumbnail_generator/
โ โโโ __init__.py # Package initialization
โ โโโ final_thumbnail_generator.py # Core generator
โ โโโ text_png_generator.py # PNG text renderer
โ โโโ api_server.py # Flask API service
โ โโโ function_add_chapter.py # Chapter functionality
โโโ templates/
โ โโโ professional_template.jpg # 1600x900 professional template
โ โโโ triangle_template.png # 200x900 triangle transition
โโโ template_samples/ # Template showcase samples
โโโ setup.py # Package setup
โโโ pyproject.toml # Modern Python packaging
โโโ README.md # Project documentation
โโโ README_API.md # Detailed API documentation
๐ Version History
v2.1 (Current) - Smart Layout Revolution
- โ PNG Overlay Technology: Text rendering separated from template, perfect control
- โ Smart Height Adjustment: Dynamically adjust layout based on content length
- โ Line Spacing Optimization: 8px line spacing, improved reading experience
- โ Triangle Transition: 200x900 diagonal separation, professional visual effects
- โ Truncation Mechanism: Smart truncation for overlong content, stable layout
- โ Dual API Support: Thumbnail + Chapter dual-function API
- โ Python Package: Installable as pip package, use in any Python project
v1.0 - Basic Functionality
- โ Professional template layout design
- โ Auto square image conversion
- โ 5-parameter input system
- โ Smart font selection
- โ Complete text effects
- โ Flask API integration
๐ Project Status
PyPI Distribution
- ๐ฆ Live on PyPI: https://pypi.org/project/youtube-thumbnail-generator/
- ๐ Global Install:
pip install youtube-thumbnail-generator - ๐ Download Stats: Available on PyPI Stats
- ๐ Latest Version: 2.1.0
- ๐ Published: August 2025
Community & Support
- โญ GitHub Stars: https://github.com/preangelleo/youtube-thumbnail-generator
- ๐ Issue Tracking: https://github.com/preangelleo/youtube-thumbnail-generator/issues
- ๐ Documentation: Complete README and API docs
- ๐ International: Full English documentation for global users
๐ฏ Best Practices
Title Text Suggestions
- Length: Recommend 50-100 characters, system auto-optimizes display
- Content: Clearly express video theme, attract viewer clicks
- Keywords: Front-load important keywords, improve search results
Image Selection Principles
- Size: Any size, system auto-converts to square
- Content: Choose visually impactful images
- Quality: Recommend high resolution, ensure clarity after scaling
๐จ Important Notes
- File Paths: Ensure all file paths are correct and files exist
- Font Dependencies: System will auto-downgrade to available fonts
- Output Overwrite: Default output
final_test.jpg, will overwrite same-name files - API Async: API uses async processing, need to poll status
- Memory Usage: Large image processing may use significant memory
๐ก Quick Start
- Install Package:
pip install youtube-thumbnail-generator - Prepare Assets: Put logos and images in corresponding directories
- Direct Test:
from youtube_thumbnail_generator import FinalThumbnailGenerator generator = FinalThumbnailGenerator("templates/professional_template.jpg") generator.generate_final_thumbnail(title="Test Title", output_path="test.jpg")
- API Service:
youtube-thumbnail-api - Check Result: Look at generated file
Start creating professional YouTube thumbnails now! ๐ฌโจ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file youtube_thumbnail_generator-2.2.0.tar.gz.
File metadata
- Download URL: youtube_thumbnail_generator-2.2.0.tar.gz
- Upload date:
- Size: 2.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6705c3c95849a965658a17665ea67603da6cf8bcfc85404dd76d8798d79da72
|
|
| MD5 |
94d216e5c431caf52d143f704b289a93
|
|
| BLAKE2b-256 |
d600206fbb54ca0a1be52d17c341d8a385c98bc8a93515d8371a9fabce18f702
|
File details
Details for the file youtube_thumbnail_generator-2.2.0-py3-none-any.whl.
File metadata
- Download URL: youtube_thumbnail_generator-2.2.0-py3-none-any.whl
- Upload date:
- Size: 2.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
955fe5cbd25afb3685d43111bed36d5f98790a8563121a6b76e9c63544c492ba
|
|
| MD5 |
6c551d0966ad33d986bdeee44b4c6f16
|
|
| BLAKE2b-256 |
aa6ca7d10df538dbd52e4d51680c0f69ed1327c79dcac025dfa1f94c7f06d5f1
|