name: codeimage description: Draw images in code. Claude writes the scene in HTML · CSS · SVG plus the browser's own graphics — GPU shaders (WebGL), real 3D (three.js, local), Canvas effects, SVG-filter textures and lighting, CSS-3D device mockups, hand-drawn lines — and the local headless Chrome captures it as PNG. No external service, account or image model; Korean text is exact. Templates: thumbnail, cover, flow diagram, bar chart, comparison, stat card, quote, list, background. Optional, only when the user asks for an AI picture: public Hugging Face Spaces. Use for requests like '이미지 만들어줘', '썸네일', '표지 이미지', '배너', '카드 뉴스', '도식 그림', '흐름도 이미지', '그래프 이미지', '배경 이미지', '3D 그림', '코드로 그림', 'SVG 로 그려줘', "make a thumbnail", "draw a diagram image".
codeimage — images drawn in code
Korean version: SKILL.ko.md. Answer the user in their language.
K=~/.claude/skills/codeimage/scripts
python3 $K/codeimg.py preflight # first time: Node · Chrome · three.js · fonts · a real render · WebGL (if missing: codeimg.py setup)
Everything below runs on this computer: Claude writes code, the local Chrome draws it. Do not call AI image services unless the user asks for an AI picture (section 5).
Choose a route
| What | Route |
|---|---|
| Text, numbers, diagrams are the point (titles, flows, charts, comparisons, summary cards) | Template (section 1) |
| A background with mood (light, texture, colour) | plate with a GPU shader style or thumbnail background (section 1–2) |
| Objects, products, small worlds, icons with depth | Real 3D — CI.three (section 2) |
| App / web screens, dashboards | Mockup — CI.mockup with the screen built in HTML (section 2) |
| Whiteboard, explainer, notes | Sketch — CI.sketch lines over a layout (section 2) |
| Anything else | Freehand scene — codeimg.py new (section 3) |
| The user explicitly wants an AI picture (photo-real person, painting style) | Optional AI (section 5) |
1. Templates — one shot list (spec.json)
{"outdir": "out", "size": "16:9", "theme": {"mode": "light", "accent": "#2563eb", "font": "sans"},
"shots": [
{"id": "thumb", "template": "thumbnail", "data": {"title": "…", "highlight": "…", "layout": "bold", "background": "aurora"}},
{"id": "bg", "template": "plate", "data": {"style": "silk", "texture": "paper"}},
{"id": "steps", "template": "flow", "data": {"title": "…", "steps": [{"label": "…", "note": "…"}]}},
{"id": "scene", "html": "scenes/s01.html", "data": {"title": "…"}}
]}
python3 $K/codeimg.py render spec.json # code only, no external calls
python3 $K/codeimg.py sheet out --out out/_sheet.png # one contact sheet for review (saves tokens)
- Templates:
thumbnailplate(text-free background)flowbarscomparestatquotelist— fields:codeimg.py templatesorreferences/templates.md. - Sizes:
16:99:161:14:54:3ogyta4or1600x900.scale2 (default) = retina sharpness. - theme:
mode(light·dark)accentaccent2accent3bgfgfont(sans·serif·impact·num). Image refs:"@shotId"or a path relative to the spec. - Thumbnail direction —
layout:split·bold·center·poster;title_style:shadow·outline·marker·plain;background(shader),texture,chips,sticker,subject(cut-out PNG),grain. platestyles — SVG:meshwavesgridringsdotsraysblocks; GPU shader:gradientaurorasilknebulaliquidtopo(aurora·nebulawantmode: dark).textureadds a surface.- Text shrinks to fit its box. If it still overflows the report shows
△ text does not fit its box— shorten the text.
2. What the browser can draw (assets/fx.js, loaded automatically)
| Helper | Draws | Notes |
|---|---|---|
CI.shader(name or GLSL, {seed, quiet, k}) | GPU fragment-shader background | presets gradient aurora silk nebula liquid topo; colours come from the theme; own GLSL gets noise fbm pal3 finish |
CI.three(async t => …, {camera, view, pos, target, x}) | real 3D: soft shadows, studio reflections, glossy / metal / emissive materials | t.box (rounded) sphere cyl cone torus capsule extrude(points) group; t.toScreen(x,y,z) pins an HTML label to a 3D point; camera: 'iso' for isometric |
CI.texture(kind) | paper · linen · concrete · noise · clouds · marble (SVG filters + lighting) | over everything, blend multiply/overlay |
CI.mockup(kind, content, {x, y, w, tilt}) | browser · phone · laptop · card frames in CSS 3D | content = an image path or an HTML element (draw the screen in HTML) |
CI.sketch(svg).line/rect/ellipse/arrow/path/underline | hand-drawn strokes, hachure fills | fill + solid: true for a plain fill |
CI.bokeh CI.stars CI.rays CI.spot CI.canvas2d | Canvas 2D light effects | |
| Kit (base.js) | CI.grain CI.chip CI.sticker CI.bubble CI.arrowSvg CI.subject CI.iso(svg) parts | flat isometric drawings in SVG |
Examples: examples/three_scene.html (3D + shader + label), examples/fx_scene.html (mockups + sketch + texture + bokeh), examples/iso_scene.html (SVG isometric kit). Tips: references/freehand.md.
3. Freehand scenes
python3 $K/codeimg.py new scenes/s01.html --size 16:9 # scaffold → draw the scene
python3 $K/codeimg.py render scenes/s01.html --size 16:9 --out out/s01.png
Inside CI.run(async () => …) use CI.h (elements) · CI.s (SVG) · CI.fit (fit text) · CI.rand(seed) · CI.mix and the helpers above. Unit var(--u) = 1% of the short side. Layer order: background (shader / plate) → objects (3D / SVG / mockups) → text (HTML) → texture / grain.
4. Local finishing tools
codeimg.py cutout pic.png --out subj.png— remove a background locally (ISNet model; first timecodeimg.py setup --cutout). Use a user-provided photo assubjectin the thumbnail.codeimg.py enhance in.png --out big.png --scale 2— upscale + sharpen.codeimg.py bench— renders the fixed set inbench/next to reference images in one sheet. Run it after template changes.
5. Optional: AI pictures (only when the user asks)
Code cannot draw a photo-real person or a painted illustration. If the user asks for an AI picture, public Hugging Face Spaces can make one without an account (about 3 a day):
python3 $K/codeimg.py gen "English scene description" --out out/bg.png --size 16:9 --style photo --space left [--model qwen]
python3 $K/codeimg.py render spec.json --ai # also run the spec's "prompt" shots
Without --ai, render skips prompt shots (an existing file is reused, nothing is called). Prompts go to a public service — never put private material in them. Models, limits, the image bank and the prompt director: references/providers.md.
Review — a finished render is not a finished job
- Build a contact sheet with
codeimg.py sheetand open it with Read (opening images one by one costs image tokens per image). - Check clipped or overlapping text, objects colliding with text, and colour fit with the theme.
- Bring the report's
△(text does not fit, image failed to load, shader error) and✗(failure) to zero. - Bar chart values come only from real data (no decorative numbers).
Delivery report
Absolute output paths, route per shot (template · shader · 3D · mockup · freehand · AI if asked), review result.
Rules
- Draw in code by default. AI pictures only on the user's request; never paid or subscription image generation.
- No network at render time: no CDNs, web fonts or remote images in scenes (three.js and fonts are local).
- Do not imitate others' trademarks or real people.
- Outputs stay in the working folder. No
/tmp.