Preventing Unintended Room Rewrites in Image-to-Image Kitchen Prompts: Scope Contracts, Color Anchors, and Cost Tiers
Ask a general image-to-image model to "make these kitchen cabinets sage green in a Scandinavian style" and the output often redraws more than the doors. A typical failure mode looks like this: the model swaps the faucet,
Ask a general image-to-image model to "make these kitchen cabinets sage green in a Scandinavian style" and the output often redraws more than the doors. A typical failure mode looks like this: the model swaps the faucet, alters cabinet door counts, turns raised panels into flat slabs, or shifts appliances to match training examples of Scandinavian kitchens.
For a homeowner testing cabinet paint before calling a painter, changing room geometry makes the preview unreliable. Repainting doors is a surface project; moving plumbing, gas lines, and windows is a structural renovation.
While building the photo restyling pipeline behind Kitchen Layout, we tried to reduce unintended room edits at the prompt-engineering layer before sending a single request to the image model. Below is the exact TypeScript prompt-composition structure we use, why we guard user notes with function replacers, and where text constraints still fall short.
(Disclosure: I build Kitchen Layout. The examples and code below come directly from our production config, with AI assistance used during drafting and editing of this write-up.)
Separating Edit Scope Into Three Prompt Contracts
Rather than exposing a single free-form prompt box, the generator compiles a structured selection (room, level, parts, style, note) into an English instruction template. Note that our static templates and preset swatch descriptions are always English, while any optional free-text custom finish or homeowner note is inserted as typed.
Each change level in kitchen.ts carries a different preservation boundary:
| Change Level | Allowed Edits | Preservation Clause Appended to Prompt |
|---|---|---|
surfaces (default) |
Only the finish of selected parts (e.g., cabinet fronts, countertops) | Keep all unselected colors, materials, objects, walls, windows, doors, ceiling, room lighting, camera angle, and every cabinet/appliance position, size, and count unchanged. |
full |
Cabinet fronts, countertops, backsplash, flooring, lighting fixtures, decor | Keep walls, windows, doors, ceiling height, camera angle, and the positions of the sink, cooktop, and refrigerator unchanged. |
scratch |
Cabinet layout, appliances, and all finishes | Keep only walls, windows, doors, and camera angle unchanged. |
When a user selects surfaces for cabinet fronts or an island, the compiler appends a part-specific geometry clause directly after the finish instruction:
const KEEP_FRONT_DETAIL =
'Keep its door panel lines, drawer divisions and handles exactly as in the photo.';
const SELECTION_PRIORITY =
'Specific color and material selections take priority over the general style and conflicting notes.';
const KEEP_ALL =
'Keep everything else exactly as in the photo. In unselected areas, preserve all colors, materials and objects. Keep walls, windows, doors, ceiling, room lighting and camera angle unchanged. Keep every cabinet, appliance, sink and fixture in its original position, size and count. Do not add, remove or move objects.';
We also scope optional style presets when level === 'surfaces' so a broad aesthetic label carries an explicit boundary:
const styleSlot = style
? `Style: ${style.prompt}.${
sel.level === 'surfaces'
? ' Apply this style only to the requested finishes, without changing existing shapes or adding objects.'
: ''
}`
: '';
Below is a sample pair generated with our surfaces contract targeting only the cabinet fronts (sage_green) on a lived-in U-shaped oak kitchen photo, leaving the speckled counters, cream backsplash tile, range, and window trim intact:
Writing Color Strings With Undertone and Saturation Cues
Single-word color names leave wide ambiguity for image edit models, especially in residential photos shot under warm household lighting or deep lower-cabinet shadows.
In our preset cabinet palette (CABINET_PALETTE), we describe each finish using value, saturation, undertone, and sheen instead of a bare color name:
-
Warm white (
#F3EEE3):"warm off-white with a subtle cream undertone and a matte finish" -
Sage green (
#9CAF88):"soft, low-saturation sage green with a light gray undertone and a matte finish" -
Deep navy (
#1F2A44):"deep, low-saturation navy blue, visibly blue rather than black"
Specifying "visibly blue rather than black" on deep navy directly addresses dark shadow collapse, and specifying "matte finish" reduces artificial glossy reflections on textured wood doors. These strings are starting presets; we still treat color accuracy as directional and rely on visual review rather than claiming guaranteed color fidelity across every bulb temperature.
Defensive Template Interpolation for User Notes
Users can append an optional note up to 300 characters (RESTYLE_NOTE_MAX = 300), and custom finishes or styles up to 80 characters (RESTYLE_CUSTOM_MAX = 80).
In JavaScript, passing a string containing replacement tokens into String.prototype.replace(regex, replacementString) expands special sequences such as $& (matched substring), $` (preceding text), and $' (following text). For example, if a user note literally contains keep $& handles and you interpolate via a string argument, $& expands into {note} inside the compiled prompt.
Using a function replacer avoids that expansion completely:
const slots: Record<string, string> = {
'{targets}': targets.length ? joinAnd(targets) : level.defaultTargets,
'{changes}': changes.join(' '),
'{style}': styleSlot,
'{note}': note ? `Homeowner's note: ${note.replace(/[.\s]+$/, '')}.` : '',
};
const prompt = level.template
.replace(/\{(targets|changes|style|note)\}/g, (slot) => slots[slot])
.replace(/\s+/g, ' ')
.trim();
This is a preventive safeguard we put directly into composeRestyle(), paired with whitespace normalization and strict character caps.
Separating Credit Pricing From Underlying Model Selection
Consumer image-editing APIs vary widely in per-image price. To avoid coupling UI copy and billing rules to a single model endpoint, output-quality.ts maps three fixed user-facing tiers (low, medium, high) to model configurations:
| Tier | User Credit Charge | Configured Model & Setting | Reference Catalog Estimate (2026-10-03) | Access Rule |
|---|---|---|---|---|
low |
1 credit |
ideogram/v4.5/edit (1k, very_low) |
~$0.008 / image | Free + Paid |
medium |
2 credits |
openai/gpt-image-2.5/flare/edit (1k, medium) |
~$0.046 / image | Paid only |
high |
5 credits |
openai/gpt-image-2.5/flare/edit (1k, high) |
~$0.098 / image | Paid only |
(The dollar figures above are catalog estimates recorded on October 3, 2026 in our config comments, not live provider invoice totals.)
Keeping free sign-up accounts restricted to the low tier (with watermarked output and Turnstile plus disposable-email checks at sign-up) lets visitors test the workflow on a real kitchen photo while keeping per-image model exposure bounded.
Where Prompt Constraints Still Fall Short
Text instructions are guardrails, not deterministic pixel locks. Even with KEEP_ALL and KEEP_FRONT_DETAIL, an image edit model can still alter small hardware, window mullions, or cabinet divisions.
In practice, two input factors matter just as much as prompt wording:
- Camera angle. Shooting straight-on at chest to eye height preserves vertical door stiles better than tilting steeply upward or downward from a step stool.
- Foreground clutter. Tall countertop appliances, dish racks, and cutting boards hide the countertop-to-backsplash boundary, forcing the model to guess what sits behind them.
Because probabilistic models can always drift on edge details, the prompt contract has to be paired with an immediate Before/After inspection control so users check openings, appliances, and proportions against their original photo before sharing concepts with a contractor.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.
