Community이미지github.com

umutc6230/code-to-image

Create structured images (illustrations, icons, diagrams, charts, UI mockups, generative art) by writing code (SVG, HTML/CSS, Canvas, matplotlib), rendering it, and visually checking the result. Do not use for photorealistic images or real photo generation.

code-to-image란 무엇인가요?

code-to-image is a Claude Code agent skill that create structured images (illustrations, icons, diagrams, charts, UI mockups, generative art) by writing code (SVG, HTML/CSS, Canvas, matplotlib), rendering it, and visually checking the result. Do not use for photorealistic images or real photo generation.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/umutc6230/code-to-image-skill/tree/HEAD

Installed? Explore more 이미지 skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

code-to-image은(는) 무엇을 하나요?

You do not generate pixels. You write code that describes the image, render it with a tool, look at the result, and fix it. Treat every image as compiled code.

1. Pick the format by subject

SubjectFormat
Icon, logo, flat illustration, badgeSVG
UI screen, card, landing section, poster with textHTML + CSS
Animation, particles, generative / algorithmic artCanvas or p5.js
3D sceneThree.js
Data chartmatplotlib / Plotly / D3
Flowchart, architecture, sequence diagramMermaid or Graphviz (DOT)
Pixel manipulation of an existing imagePython PIL / OpenCV

If the user named a format, use it. Otherwise pick the simplest one that fits.

2. Plan before writing code

Write a short plan first (it can be in comments):

  • Canvas size and aspect ratio (for example, a 800x600 viewBox).
  • A layout grid: main subject position, margins, the reading order.
  • Layers from back to front: background, main shapes, details, text.
  • A palette of 3–5 colors with enough contrast (aim for WCAG AA against the background for any text).
  • Every element gets explicit coordinates. Never say "roughly in the middle". Compute it.

3. Write the code

  • Self-contained: inline styles, no external assets unless provided, embed fonts only if needed and fall back to system fonts.
  • Use groups (<g>), named IDs and comments so the image stays editable.
  • Prefer simple primitives (circle, rect, path with few points) over long freehand paths. Build complex shapes by combining simple ones.
  • Keep text as real text, not paths, so it stays crisp and editable. Check that text fits its box.
  • For generative art, use a seeded random generator so results are reproducible.

4. Render

Save the code to a file and render it to PNG. Use the bundled helper in this skill's scripts/render.py directory for common formats:

python <skill-dir>/scripts/render.py input.svg   # also .html, .mmd, .dot -> input.png
python <skill-dir>/scripts/render.py card.html --width 1080 --height 1080 --no-full-page

Or render directly:

  • SVG: rsvg-convert -w 1200 in.svg -o out.png or Python cairosvg.svg2png(url="in.svg", write_to="out.png")
  • HTML/Canvas/p5/Three.js: headless browser screenshot (for example, Playwright: page.goto("file://..."), wait for render, page.screenshot(path="out.png"))
  • matplotlib: plt.savefig("out.png", dpi=150, bbox_inches="tight")
  • Mermaid: mmdc -i in.mmd -o out.png; Graphviz: dot -Tpng in.dot -o out.png

If no render tool is available, skip to delivery and say the image has not been visually verified.

5. Inspect and fix (max 3 rounds)

Open the PNG and check it with vision:

  • Overlapping or clipped elements, text spilling out of boxes
  • Elements outside the canvas or crowded against an edge
  • Proportions that look wrong, uneven spacing, misaligned items
  • Low-contrast text, colors that clash
  • Does it actually show what the user asked for?

Fix the specific issue in code and re-render. Stop after 3 rounds or when nothing significant is left.

6. Deliver

  • Give the source file (SVG/HTML/py) plus the rendered PNG.
  • One line on what it shows and what is easy to change (colors, text, sizes).

Limits and rules

  • Code-drawn images are strong for structure (diagrams, icons, UI, charts, typography) and weak for photorealism, faces, fur, complex textures. Say so and offer a stylized version instead of a bad realistic one.
  • Do not draw copyrighted characters, mascots, brand logos or reproductions of existing artworks. Create original designs instead.
  • Do not depict real identifiable people.

관련 스킬