A Telegram bot that generates beautiful AnimeFlicker-style thumbnails for anime series.
- 🎨 Honeycomb poster design - Unique hexagonal pattern overlay on anime poster
- 📝 Auto-fetches anime info - Gets title, rating, genres, and description from AniList
- 🔤 Robust font handling - Multiple fallback fonts with graceful degradation
- 🖼️ Placeholder support - Generates placeholder image when poster is unavailable
- ✨ Text outlines - Black stroke around text for better readability on any background
- 📐 Smart text handling - Auto-wrapping and truncation with ellipsis for long titles
- Python 3.7+
- PIL/Pillow
pip install -r requirements.txtSet your Telegram bot token:
export BOT_TOKEN="your_telegram_bot_token_here"python thumbnail.py- Start a chat with your bot
- Send
/thumb <anime name>(e.g.,/thumb Attack on Titan) - The bot will generate and send the thumbnail
The generator uses a fallback font loading system:
BebasNeue-Regular.ttf(root directory)fonts/BebasNeue-Regular.ttffonts/Roboto-Bold.ttf- System default font
fonts/Roboto-SemiBold.ttffonts/Roboto-Bold.ttffonts/Roboto-Medium.ttfBebasNeue-Regular.ttf- System default font
To use custom fonts:
- Place
.ttffiles in thefonts/directory - Update the font path constants in
thumbnail.py
Edit these constants in thumbnail.py to adjust font sizes:
TITLE_FONT_SIZE = 128 # Anime title (reduced from 160)
BOLD_FONT_SIZE = 42 # Buttons
MEDIUM_FONT_SIZE = 36 # Logo text
REG_FONT_SIZE = 30 # Description, rating
GENRE_FONT_SIZE = 38 # Genre tags
FONT_SCALE = 1.0 # Global scaling factor (1.0 = 100%)When a poster image fails to load, the generator creates a placeholder automatically.
To use a custom placeholder image:
- Create
assets/placeholder.jpg - The generator will use it instead of the programmatic placeholder
PLACEHOLDER_BG_COLOR = (30, 40, 70) # Dark blue background
PLACEHOLDER_TEXT = "NO IMAGE" # Centered text
PLACEHOLDER_PATH = "assets/placeholder.jpg" # Custom placeholder pathThe generator includes text outlines for better readability:
TEXT_OUTLINE_COLOR = (0, 0, 0) # Black outline
TEXT_OUTLINE_WIDTH = 2 # Pixels for body text
TITLE_OUTLINE_WIDTH = 3 # Pixels for title text- Max width: 650 pixels before wrapping
- Max characters: 50 before truncation with "..."
- Max lines: 2 lines displayed
Run the test script to validate thumbnail generation:
python test_thumbnail.pyThis tests:
- Font loading with fallbacks
- Placeholder image generation
- Text outline rendering
- Title truncation for long titles
Test outputs are saved to /tmp/test_*.png for visual inspection.
thumbgen/
├── thumbnail.py # Main bot and thumbnail generator
├── test_thumbnail.py # Test script for validation
├── requirements.txt # Python dependencies
├── BebasNeue-Regular.ttf # Title font
├── fonts/ # Additional fonts
│ ├── Roboto-*.ttf # Roboto font family
│ └── hex_bg.png # Pre-generated hex background
├── background.jpg # Background image (optional)
├── plp.jpg # Poster layout placeholder (optional)
└── assets/ # Custom assets (optional)
└── placeholder.jpg # Custom placeholder image
For Heroku or similar platforms, a Procfile is included:
worker: python thumbnail.py
This project uses the following open-source fonts:
- Bebas Neue - SIL Open Font License
- Roboto - Apache License 2.0
This is normal if some font files are missing or empty. The generator will use fallback fonts automatically.
The poster URL was unreachable. Check your internet connection or the AniList API status.
Adjust FONT_SCALE in thumbnail.py:
FONT_SCALE = 1.2for 20% largerFONT_SCALE = 0.8for 20% smaller