Generate Meme PNGs from Templates with Pillow Text Overlay
Create meme PNGs from templates with Pillow text overlay.
Written by Neura Market from the official Hermes Agent documentation for Meme Generation. Commands, paths, and version numbers are reproduced from the source unchanged.
Read the official documentationThis skill turns a topic or caption into a real .png meme file. You pick a template, write short captions, and the script renders the image with text overlaid using Pillow. Reach for it when a user asks for a meme, wants a visual joke about a specific situation, or says "meme this."
What it does
The skill generates meme images from a topic. It selects a template, writes captions for each text field, and produces a .png file with text overlay. Two modes exist: classic template mode uses one of ~100 popular imgflip templates or 10 curated templates with hand-tuned text positioning; custom AI image mode overlays text onto a scene you generate with an image generation tool.
Before you start
- The skill is optional and installed on demand. Its path is
optional-skills/creative/meme-generation. - Version 2.0.0, authored by adanaleycio, MIT license.
- Works on linux, macos, windows.
- Requires Python with Pillow installed. The script uses
Pillowfor text rendering. - The script caches template images in
scripts/.cache/after first download. - Related skill: ascii-art.
Available Templates
The script supports any of the ~100 popular imgflip templates by name or ID, plus 10 curated templates with hand-tuned text positioning.
Curated Templates (custom text placement)
| ID | Name | Fields | Best for |
|---|---|---|---|
this-is-fine | This is Fine | top, bottom | chaos, denial |
drake | Drake Hotline Bling | reject, approve | rejecting/preferring |
distracted-boyfriend | Distracted Boyfriend | distraction, current, person | temptation, shifting priorities |
two-buttons | Two Buttons | left, right, person | impossible choice |
expanding-brain | Expanding Brain | 4 levels | escalating irony |
change-my-mind | Change My Mind | statement | hot takes |
woman-yelling-at-cat | Woman Yelling at Cat | woman, cat | arguments |
one-does-not-simply | One Does Not Simply | top, bottom | deceptively hard things |
grus-plan | Gru's Plan | step1-3, realization | plans that backfire |
batman-slapping-robin | Batman Slapping Robin | robin, batman | shutting down bad ideas |
Dynamic Templates (from imgflip API)
Any template not in the curated list can be used by name or imgflip ID. These get smart default text positioning (top/bottom for 2-field, evenly spaced for 3+). Search with:
python "$SKILL_DIR/scripts/generate_meme.py" --search "disaster"
Procedure
Mode 1: Classic Template (default)
- Read the user's topic and identify the core dynamic (chaos, dilemma, preference, irony, etc.)
- Pick the template that best matches. Use the "Best for" column, or search with
--search. - Write short captions for each field (8-12 words max per field, shorter is better).
- Find the skill's script directory:
SKILL_DIR=$(dirname "$(find ~/.hermes/skills -path '*/meme-generation/SKILL.md' 2>/dev/null | head -1)")
- Run the generator:
python "$SKILL_DIR/scripts/generate_meme.py" <template_id> /tmp/meme.png "caption 1" "caption 2" ...
- Return the image with
MEDIA:/tmp/meme.png
Mode 2: Custom AI Image (when image_generate is available)
Use this when no classic template fits, or when the user wants something original.
-
Write the captions first.
-
Use
image_generateto create a scene that matches the meme concept. Do NOT include any text in the image prompt, text will be added by the script. Describe only the visual scene. -
Find the generated image path from the image_generate result URL. Download it to a local path if needed.
-
Run the script with
--imageto overlay text, choosing a mode:- Overlay (text directly on image, white with black outline):
python "$SKILL_DIR/scripts/generate_meme.py" --image /path/to/scene.png /tmp/meme.png "top text" "bottom text"
- **Bars** (black bars above/below with white text, cleaner, always readable):
python "$SKILL_DIR/scripts/generate_meme.py" --image /path/to/scene.png --bars /tmp/meme.png "top text" "bottom text"
Use --bars when the image is busy/detailed and text would be hard to read on top of it.
5. Verify with vision (if vision_analyze is available): Check the result looks good:
vision_analyze(image_url="/tmp/meme.png", question="Is the text legible and well-positioned? Does the meme work visually?")
If the vision model flags issues (text hard to read, bad placement, etc.), try the other mode (switch between overlay and bars) or regenerate the scene.
6. Return the image with MEDIA:/tmp/meme.png
Examples
"debugging production at 2 AM":
python generate_meme.py this-is-fine /tmp/meme.png "SERVERS ARE ON FIRE" "This is fine"
"choosing between sleep and one more episode":
python generate_meme.py drake /tmp/meme.png "Getting 8 hours of sleep" "One more episode at 3 AM"
"the stages of a Monday morning":
python generate_meme.py expanding-brain /tmp/meme.png "Setting an alarm" "Setting 5 alarms" "Sleeping through all alarms" "Working from bed"
Listing Templates
To see all available templates:
python generate_meme.py --list
Pitfalls
- Keep captions SHORT. Memes with long text look terrible.
- Match the number of text arguments to the template's field count.
- Pick the template that fits the joke structure, not just the topic.
- Do not generate hateful, abusive, or personally targeted content.
- The script caches template images in
scripts/.cache/after first download.
Verification
The output is correct if:
- A .png file was created at the output path
- Text is legible (white with black outline) on the template
- The joke lands, caption matches the template's intended structure
- File can be delivered via MEDIA: path
When not to use it
If the user wants a purely text-based joke or a simple ASCII art representation, the related ascii-art skill may be more appropriate. This skill is specifically for generating image-based memes.
Limits and gotchas
- The script relies on the imgflip API for dynamic templates; network access is required for first-time downloads of those templates.
- Curated templates have hand-tuned text positions that may not work well with very long captions.
- The custom AI image mode requires the
image_generatetool to be available in the agent's environment. - Vision verification requires the
vision_analyzetool; without it, you cannot automatically check legibility.
What pairs with this
The related skill ascii-art provides a text-based alternative for meme-like output when image generation is not desired or possible.