con un clic
render
// Generate raster images (PNG, JPEG, WebP) from natural language prompts using Python rendering engines. Covers graphics, charts, layouts, and procedural art. Not for SVG output.
// Generate raster images (PNG, JPEG, WebP) from natural language prompts using Python rendering engines. Covers graphics, charts, layouts, and procedural art. Not for SVG output.
| name | render |
| description | Generate raster images (PNG, JPEG, WebP) from natural language prompts using Python rendering engines. Covers graphics, charts, layouts, and procedural art. Not for SVG output. |
Generate professional raster images by routing each request to the best rendering engine. You write Python code; the engine does the pixel work.
./references/pdm run python <script.py> (to use the plugin's venv), verify the output, deliver the imageEnvironment: This plugin uses a pdm-managed virtual environment. Always run generation scripts with
pdm run pythonfrom the plugin root. If pdm is not set up yet, runpython scripts/setup.pyfirst.
| Request type | Engine | Reference file |
|---|---|---|
| Photo manipulation, compositing, filters, pixel ops, simple graphics | Pillow | ./references/pillow.md |
| Clean vector-style graphics, logos, icons, anti-aliased shapes, typography-heavy designs | Cairo | ./references/cairo.md |
| Statistical charts, scientific plots, data visualization (static) | Matplotlib + Seaborn | ./references/matplotlib.md |
| Complex interactive-looking dashboards, rich data viz with annotations | Plotly (static export) | ./references/plotly.md |
| Complex layouts, HTML/CSS designs, UI mockups, anything with web fonts or CSS effects | Playwright (HTML→PNG) | ./references/playwright.md |
Some requests need two engines. Common combos:
When combining engines, save intermediate outputs as temporary PNGs and load them in the second engine.
These files contain cross-engine patterns — read them before the engine docs:
./shared/setup.md — Installation, pdm setup, running scripts./shared/fonts.md — Font directory resolution, per-engine loading, font selection guide./shared/canvas.md — Dimensions, size presets, retina scaling, output saving (PNG/JPEG/WebP)./shared/themes.md — Dark/light themes, color tokens, categorical/sequential/diverging palettesAll generated files go into the generated/ directory at the plugin root:
generated/
<slug>_render.py # generation script
<slug>.png # output image
generated/<slug>_render.py where <slug> is a
short kebab-case name derived from the request (e.g., social-card_render.py)generated/<slug>.png (or .jpg/.webp)generated/ too — prefix with _tmp_generated/ directory is gitignored. Do NOT place scripts in scripts/
or output in output/ — those are not for generated artifacts._tmp_* files.Every generation script should follow this pattern:
#!/usr/bin/env python3
"""Rasterize: [brief description of what this generates]"""
import os
# === CONFIGURATION ===
WIDTH, HEIGHT = 1200, 630 # Logical dimensions
SCALE = 2 # Retina multiplier
# Paths — all generated files go in generated/
PLUGIN_ROOT = os.path.dirname(os.path.abspath(__file__))
GENERATED_DIR = os.path.join(PLUGIN_ROOT, "generated")
os.makedirs(GENERATED_DIR, exist_ok=True)
OUTPUT_PATH = os.path.join(GENERATED_DIR, "<slug>.png")
FONT_DIR = os.path.join(PLUGIN_ROOT, "assets", "fonts")
# Engine-specific imports here
# === HELPERS ===
# Reusable drawing functions here
# === COMPOSITION ===
def render():
# Main rendering logic
# ...
pass
# === EXECUTE ===
if __name__ == "__main__":
render()
print(f"Saved to {OUTPUT_PATH}")
When generating images, aim for professional quality:
./shared/setup.md../shared/fonts.md). Never use system fonts
without checking availability.Before writing a generation script, ALWAYS read the relevant engine
reference doc from ./references/. These contain engine-specific
patterns, gotchas, and helper snippets that prevent common mistakes.
./references/pillow.md — Pillow patterns and helpers./references/cairo.md — PyCairo patterns and helpers./references/matplotlib.md — Matplotlib + Seaborn patterns./references/plotly.md — Plotly static export patterns./references/playwright.md — HTML-to-PNG via Playwright