Generate beautiful infographics by combining AI-generated backgrounds with pixel-perfect HTML text overlays.
rembg to make hero elements transparentUse rembg (installed in sdxl-env) to remove backgrounds from hero elements:
source ~/ai-tools/sdxl-env/bin/activate
python -c "
from rembg import remove
from PIL import Image
input_img = Image.open('input.png')
output_img = remove(input_img)
output_img.save('output_transparent.png')
"
This ensures clean compositing without white boxes around elements.
~/bin/sdxl "abstract infographic background, [THEME KEYWORDS], flowing lines, charts, graphs, icons, gradient [COLORS], professional business style, no text, minimal" -o /tmp/infographic_bg.png --model playground --steps 25
Theme keyword examples:
Template structure (save to /tmp/infographic.html):
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap" rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1024px;
height: 1024px;
font-family: 'Inter', sans-serif;
background: url('/tmp/infographic_bg.png') center/cover;
color: white;
}
.overlay {
position: absolute;
inset: 0;
background: rgba(0,0,0,0.3); /* Adjust opacity for readability */
display: flex;
flex-direction: column;
padding: 60px;
}
.title { font-size: 48px; font-weight: 900; text-transform: uppercase; }
.stat-number {
font-size: 96px;
font-weight: 900;
background: linear-gradient(135deg, #00d4ff, #a855f7);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.stat-label { font-size: 28px; font-weight: 600; }
</style>
</head>
<body>
<div class="overlay">
<!-- Title, stats, content here -->
</div>
</body>
</html>
Customization tips:
.overlay background opacity based on background complexity# Run in sdxl-env (has Playwright installed)
source ~/ai-tools/sdxl-env/bin/activate
python -c "
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(viewport={'width': 1024, 'height': 1024})
page.goto('file:///tmp/infographic.html')
page.wait_for_timeout(1000) # Let fonts load
page.screenshot(path='/tmp/infographic_final.png')
browser.close()
"
| Component | Tool | Notes |
|---|---|---|
| Background | ~/bin/sdxl --model playground |
Abstract, no text |
| Hero elements | ~/bin/sdxl --model playground |
Characters, icons, use “transparent background style” |
| Text overlay | HTML + CSS | Use Inter font, gradient numbers, glass-morphism cards |
| Emoji | Twemoji or Segoe UI Emoji | Visual interest without extra image gen |
| Screenshot | Playwright (in sdxl-env) | 1024x1024 viewport |
Use emoji for quick visual accents in stats or labels:
Twemoji (cross-platform, consistent):
<script src="https://cdn.jsdelivr.net/npm/@twemoji/api@latest/dist/twemoji.min.js"></script>
<script>twemoji.parse(document.body)</script>
Segoe UI Emoji (Windows Fluent style):
.emoji { font-family: 'Segoe UI Emoji', sans-serif; }
Example usage:
<div class="stat">
<span class="emoji">🚀</span>
<span class="stat-number">67%</span>
<span class="stat-label">adoption rate</span>
</div>
Good emoji for infographics: 📈 💰 ⚡ 🎯 🔥 🚀 💡 ✨ 🤖 📊 💼 🏆
For generating composable elements with clean edges:
# Character/mascot
~/bin/sdxl "friendly AI robot assistant, cute robot character, glowing eyes, transparent background style, minimal, clean illustration" --model playground
# Icons
~/bin/sdxl "3D icon of [SUBJECT], glossy, minimal, transparent background, clean" --model playground
# Abstract shapes
~/bin/sdxl "abstract glowing orb, energy sphere, transparent background, minimal" --model playground
Use CSS to layer multiple AI-generated elements:
<body style="background: url('background.png') center/cover;">
<img src="robot.png" class="hero-element" />
<div class="text-overlay">
<!-- Stats and text here -->
</div>
</body>
Glass-morphism stat cards:
.stat-card {
background: rgba(255,255,255,0.1);
backdrop-filter: blur(10px);
border-radius: 16px;
border: 1px solid rgba(255,255,255,0.2);
}
Tech/Data (blue-purple):
#1a1a2e → #4a1a6b#00d4ff, #a855f7Business (blue-teal):
#0f172a → #134e4a#38bdf8, #2dd4bfBold (orange-pink):
#1f1f1f → #3d1a1a#f97316, #ec4899