social-card

Generate beautiful social card images with a fluent builder API. OG, Twitter, and GitHub presets with dark, light, and midnight themes. Single dependency: Pillow.

pip install social-card

Quickstart

from social_card import SocialCard SocialCard("og") \ .title("My Project") \ .subtitle("A cool tool for builders") \ .badge("huje.tools") \ .footer("pip install my-project") \ .accent("#f97316") \ .glow() \ .render("card.png")

Presets

Choose a preset to set the canvas size for your target platform.

PresetSizeUse Case
og1200x630Open Graph (Facebook, LinkedIn, general)
twitter800x418Twitter/X cards
github1280x640GitHub repository social preview
square1080x1080Instagram, general square format

Themes

Built-in color themes for quick styling.

ThemeBackgroundTextAccent
dark#0f172a#f8fafc#3b82f6
light#ffffff#0f172a#3b82f6
midnight#030712#f9fafb#8b5cf6

Builder API

All methods return self for fluent chaining.

MethodDescription
.badge(text)Small label at top
.title(text)Main heading
.subtitle(text)Description below title
.footer(text)Bottom text
.accent(color)Override accent color
.cards(labels)Mini card pills
.skill_cards(skills)Structured skill cards with name, label, code
.grid()Background grid pattern
.glow()Accent color glow effect
.render(path) → ImageSave to file
.render_bytes(fmt="PNG") → bytesReturn as bytes

Skill Cards Example

SocialCard("og").skill_cards([ {"name": "Nostr|Key", "label": "Identity", "code": "pip install nostrkey"}, {"name": "sense-memory", "label": "Persistence", "code": "pip install sense-memory"}, ]).render("skills.png")

Security

Dependency

Pillow — that's it.

Part of the huje.tools Ecosystem

social-card is part of huje.tools. It's used across the Humanjava ecosystem to generate OG images for landing pages, PyPI packages, and social shares. The OG images on this very site were generated with social-card.