Communitygithub.com

image-to-ui

Reproduce a design image — screenshot, photo of a screen, mockup, Figma/Dribbble export, AI-generated concept board, wireframe or sketch — as working UI code in the user's real project (React Native/Expo or web: React, HTML/CSS, Tailwind), as close to the picture as possible, then render it, screenshot it and compare it element by element with the image until it matches. Use this whenever the user shares or points to an image of a screen or component and wants it built, recreated, matched, "сверстать по макету", "сделать как на картинке", "перенести дизайн в код", "точно как на скрине", or asks why their screen does not look like the mockup — even if they never say "skill", "pixel-perfect" or name a framework.

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

image-to-ui is a Claude Code agent skill that reproduce a design image — screenshot, photo of a screen, mockup, Figma/Dribbble export, AI-generated concept board, wireframe or sketch — as working UI code in the user's real project (React Native/Expo or web: React, HTML/CSS, Tailwind), as close to the picture as possible, then render it, screenshot it and compare it element by element with the image until it matches. Use this whenever the user shares or points to an image of a screen or component and wants it built, recreated, matched, "сверстать по макету", "сделать как на картинке", "перенести дизайн в код", "точно как на скрине", or asks why their screen does not look like the mockup — even if they never say "skill", "pixel-perfect" or name a framework.

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

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

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

문서


name: image-to-ui description: Reproduce a design image — screenshot, photo of a screen, mockup, Figma/Dribbble export, AI-generated concept board, wireframe or sketch — as working UI code in the user's real project (React Native/Expo or web: React, HTML/CSS, Tailwind), as close to the picture as possible, then render it, screenshot it and compare it element by element with the image until it matches. Use this whenever the user shares or points to an image of a screen or component and wants it built, recreated, matched, "сверстать по макету", "сделать как на картинке", "перенести дизайн в код", "точно как на скрине", or asks why their screen does not look like the mockup — even if they never say "skill", "pixel-perfect" or name a framework.

Image → UI

Reproduce what the picture shows as exactly as the platform allows, in the user's real project, and prove it with measurements of a rendered screenshot against the picture.

The picture is the specification. The user reads every visible difference — an icon that is "almost the same", a label that wraps where the picture has one line, a grey where the picture has green — as a failure. So the default here is fidelity, and every remaining difference must be either physically impossible to remove or explicitly requested.

Two facts shape the workflow:

  • You see the image downscaled. A 1206 px screenshot reaches you at about half size, so 12 vs 16 pt, a 1 px border or #0d9488 vs #14b8a6 are below what you can eyeball. Measure with scripts/imgtool.py.
  • "Looks right" drifts. Only numbers from a rendered screenshot against the picture — element positions, sizes, colours — show what is still off. The loop ends with a measured match.

Scripts live next to this file (<skill-dir>/scripts/): Python 3 + Pillow, and Node with Playwright (resolved from the project or an installed playwright-skill). Keep crops, grids, screenshots and notes in a temp/scratchpad folder, not in the repo. Talk to the user in their language.

1. Pin down the ask

Settle from the request, the image and the repo — ask only what you cannot find out:

  • What: whole screen, one region or one component; new code or a restyle of existing code (then find the existing code first and change it in place).
  • Where: the file/route/component it belongs in, following the project's conventions.
  • Fidelity: exact by default — the picture wins over tokens, component limits and style habits. Use the project's design tokens only where they equal the measured value (ΔE < 2, size within 0.5 pt); otherwise use the measured value. Switch to system mode (snap to the design system, accept visible differences) only if the user asks for it ("в стиле проекта", "через дизайн-систему", "примерно").

When the picture contradicts a written project rule

The picture wins: build what it shows. Then say so explicitly in the report — which rule (file and section), which element breaks it, and what the rule-abiding alternative would be — so the owner decides knowingly. Two things still hold:

  • Don't weaken the project's checks to make the picture pass: no editing, skipping or deleting a test or guard. If a guard fails because of the picture, leave it failing and name it in the report.
  • Don't invent rules. "It might read as an alarm", "icons per item feel like classification", "the component only supports 18 pt icons", "locale files are edited in separate tasks" are not rules against the picture — they are reasons to extend a component, add a key, or note a follow-up. Only a written rule counts, and only if it actually says so.

2. Read the image

python3 scripts/imgtool.py info <image> — pixel size, likely device scale and logical size, background, dominant and accent colours.

What kind of image is it?

KindTreatment
Real screenshot / design-tool exportPrecise. Every value is intended.
Photo of a screenFirst unwarp (perspective) and balance (colour cast from a known white), then treat as a screenshot with ±1 pt / small ΔE tolerance. The aspect ratio is not recoverable from the four corners alone — fix --width from a known width (container, viewport) and set --height so that something of known proportions comes out right: a round badge/avatar is round, a square icon is square, a text line rendered by font_candidates at the matched width has the photo's height, or the device's screen ratio if the whole screen is in frame. A 2 % stretch is invisible by eye and shifts every row.
AI-generated concept or boardStill match sizes, positions, colours, icons, texts and line breaks exactly; only synthetic glyph shapes and photos are exempt.
Board with phone frame + annotationsgrid, then crop the screen out; read the annotations — they are requirements too.
Wireframe / sketchLayout and hierarchy; styling from the design system.

If the width matches no device, you are looking at a board or crop: find the screen with grid and cut it out with crop. For a crop of unknown scale, pass --scale explicitly everywhere (logical = px × device_width / screen_px_width).

Measure every element, not the overall impression:

  • elements <img> [--region x y w h --logical] — boxes (x, y, w, h) and true colour of every text run, icon and panel, recursing into cards, chips and buttons. This is your layout spec.
  • typo <img> --region … --logical — per distinct text style: font size (from cap height), weight hint, colour. Confirm family/size/weight with node scripts/font_candidates.mjs --text "<exact text>" --sizes 13,14,15 --weights 400,500,600 --fonts "<project fonts as Name=file.ttf>,system-ui" --ref <crop.png> --ref-scale <px per pt>: pick the row whose width and look match the reference crop.
  • crop <img> x y w h --logical --zoom 4 — every icon, badge and border up close.
  • sample / palette --region — colours of fills, borders, backgrounds (the page background counts too).
  • bands — vertical rhythm when you need gaps between rows.

Write the spec sheet (a markdown file in the work folder) from these numbers:

Reference: <path> · <kind> · <px> · @<scale> → <logical size>
Text styles: title 15/600 #1e293b · label 12.5/500 #2b3a57 · value 17/700 #0f172a …
Elements (logical, from `elements`):
  card      x16 y72 w370 h212  fill #ffffff  border 1 #e8edf2  radius 16  shadow soft
  chip      x284 y84 w86 h22   fill #e6f6f5  text "от 29 мая 2024" 11/500 #0f8b8d
  row 1     icon plate 40×40 r12 #fde8ea · drop icon 20 #e04b5c · "Гемоглобин" …
Icons: <for each: shape description → chosen glyph and set>
Exact texts (character for character, including prepositions and units): …
Line breaks: which texts wrap and where (a two-line label in the picture stays two lines)
Unclear: …

3. Learn the project

  • Stack: package.json (expo/react-native → references/react-native.md; web → references/web.md).
  • Tokens (theme files, tailwind.config.*, CSS variables), components (components/ui), icon sets, fonts (package.json font packages, useFonts maps), i18n.
  • A screen that already looks like the target — copy its structure.
  • Project rules (CLAUDE.md, AGENTS.md, design docs) — to know where the picture conflicts with them (§1), which checks to run, and how changes are delivered.

python3 scripts/imgtool.py nearest '#0e9689' --tokens <theme files>: a token is used only when it is "same" (ΔE < 2); otherwise the measured value goes in (as a named constant next to the component, or a new token if the project adds tokens that way).

4. Build

  • Layout with flex/grid and the measured paddings/gaps — no absolute positioning tuned to pixels.
  • Icons: match the glyph, size, stroke weight, colour and plate of each one separately. Search the project's icon set for the shape (list its names, try 3–6 candidates, render them next to the zoomed crop, keep the closest). Per-item icons and colours in the picture stay per-item. If no glyph is close and SVG is available, draw it.
  • Text: exactly the picture's strings. If an i18n key with the right text doesn't exist, add one (in every locale the project requires), rather than reusing a key with different wording. Match line breaks: if the picture fits a label on one line at this width, choose the size and letter-spacing that fit — verify at the reference's device width.
  • Fonts: use the family font_candidates matched. If the project's font can't render the text (e.g. no Cyrillic) or the picture's font isn't installed, use the closest available one and report it as the one unavoidable difference; propose adding the font.
  • Components: reuse when they can produce the picture; when they can't (fixed icon size, fixed weight, alignment), add a variant/prop or build a local component — don't bend the picture to the component.
  • Never ship the reference itself (no screenshot or slice of it as an image in the UI).
  • Keep accessibility: labels, roles, touch targets (44 pt iOS / 48 dp Android).

5. Render and screenshot

Match the reference's logical size and scale, and render the same state and data as the picture (same texts, numbers, dates) — otherwise every text box differs for a reason that isn't design.

  • Web: node scripts/capture_web.mjs --url <url> | --file x.html | --serve dist --out shot.png --width <logical w> --height <logical h> --scale <scale> [--selector …] --dump-text.
  • React Native / Expo: references/react-native.md — browser preview of one component (scripts/rn_web_preview.mjs), the running app on a simulator, or the project's own harness.

Read capture_web's report before the pixels: blocked hosts, 404s (fonts!), page errors, the visible text. An empty or half-rendered page is a setup problem, not a design difference. External requests are blocked by default so project code cannot reach a real backend.

If rendering is impossible here, say so plainly, and still review code against the spec sheet.

6. Compare and fix — until it stops improving (max 5 rounds)

Each round:

  1. imgtool.py compare <ref> <shot> --out cmp.png [--trim] [--crop-ref …] [--crop-shot …] — the overall picture and mismatch %. Open it.
  2. imgtool.py geometry <ref> <shot> [--trim | --crop-ref/--crop-shot] [--scale s] — every element's dx, dy, dw, dh and colour ΔE. Everything flagged <- is on the fix list; MISSING / EXTRA elements are structural bugs.
  3. imgtool.py pair <ref> <shot> --region x y w h --zoom 4 for the worst offenders — icons, glyph weight, borders, radii, shadows.
  4. Fix all of it, re-render, repeat.

Stop when geometry shows no element off by more than 1 pt (or the tolerance the image kind allows) and colours are within ΔE 3 — or when a round no longer improves anything and each remaining delta has a written reason (font not installed, synthetic glyphs, photo content, user-requested system mode). Never lower the numbers with tricks such as absolute positioning or embedding the image.

7. Report

In the user's language, short:

  • Built: files created/changed; where the component is used.
  • Evidence: final composite path; mismatch % and "elements off > 1 pt" — first round → last.
  • Remaining differences, each with its reason (only the unavoidable kind).
  • Conflicts with project rules (if any): rule, file/section, element, the rule-abiding alternative; any check that now fails because of it.
  • Not verified: what you could not render or check (e.g. device fonts vs browser).
  • Follow-ups: fonts or tokens to add, states the picture doesn't show.

관련 스킬