Stop AI image edits from changing other parts: one edit per turn
Editing multiple elements at once causes room layout and lighting drift. Use single-target prompts per turn and check drift with ImageMagick.
Asking an image generator to change a sofa color, enlarge a window, and add a cat in a single prompt can change more than the sofa, such as wall color or lighting. The official guidance recommends splitting complex requests into steps and changing one thing at a time, so this guide turns that into a prompt template and a diff-check script. Just as our character consistency guide locks character appearance with reference parameters, conversational image editing requires targeted modifications and explicit preservation constraints to prevent background drift.
[1] The more you ask for in one request, the more room there is for untouched parts to change. No images were generated for this guide, so the three rules below follow the official recommendations:
- Maintain session continuity: Submit follow-up instructions within the same chat conversation where the initial image was created.
- Target one element per turn: Restrict each instruction to a single visual component.
- Enforce explicit preservation constraints: Explicitly list elements, lighting conditions, and framing angles that must remain unchanged.
[2] Structure prompts using a reusable template. Separate the modification target with {brackets} and list preserved background elements at the bottom.
In the image above, modify only {target_object}: {change_description}. Keep the following elements exactly the same as the previous image:- Camera framing and perspective: {camera_framing}- Lighting direction and color temperature: {lighting_condition}- Surrounding structures: {preserved_elements} Do not add, remove, or modify any other objects in the scene.{target_object}: The single entity to modify (e.g.,the sofa,the living room window){change_description}: Specific attributes to alter (e.g.,change color from navy blue to olive green){camera_framing}: Camera framing angle (e.g.,eye-level straight-on wide shot){lighting_condition}: Light direction and color temperature (e.g.,warm morning sunlight from the left){preserved_elements}: Surrounding elements to preserve (e.g.,flooring, wall color, coffee table)
[3] The two prompt strategies below are designed for a synthetic 1920x1080 living room image. The goal comprises three edits: change the navy sofa to olive green, double the width of the left window with sheer white curtains, and place a sleeping orange tabby cat on the rug.
Method A combines all three requests into a single prompt.
In the living room image just generated, change the sofa color to olive green, make the window twice as large with sheer white curtains, and add a sleeping orange tabby cat on the floor rug.Method B executes one change per turn over three conversational turns in the same thread.
[Turn 1] In the image above, change only the sofa color from navy blue to olive green. Keep the sofa shape and texture, room layout, wall color, flooring, lighting direction, and window size exactly the same as the previous image. [Turn 2] In the updated image, enlarge only the living room window on the left wall to twice its current width and add sheer translucent white curtains. Keep the olive green sofa, floor rug, room architecture, and natural daylight tone exactly the same without altering any other furniture. [Turn 3] In the latest image, add a single sleeping orange tabby cat curled up on the center of the floor rug in front of the sofa. Keep the olive green sofa, enlarged window and curtains, floor pattern, furniture placement, and lighting identical, and do not modify any other part of the room.The table below is not a measurement from generated images. It holds made-up example values to show the input format of the check script. Method A was never run, so it has no measurement.
| Approach | Turn | Modification request | Changed pixels outside the target (example value) | Share of all 2,073,600 pixels |
|---|---|---|---|---|
| Method A | Turn 1 (all) | Change sofa, window, add cat | not measured | not measured |
| Method B | Turn 1 | Sofa color only (navy to olive green) | 1,820 | 0.09% |
| Method B | Turn 2 | Enlarge left window 2x and add curtains | 2,150 | 0.10% |
| Method B | Turn 3 | Add sleeping orange tabby on rug | 980 | 0.05% |
The three Method B rows only show what shape of log the script reads; they do not claim that real edits come out this way. How much Method A changes was not tested in this run. Try both on your own image and fill the log in the same format.
[4] Write a verification script to audit pixel stability. Compare each turn against the previous frame using ImageMagick compare -metric AE, then log total changed pixels and changed pixels outside the target bounding box to diff_log.tsv. outside_px is that outside count, and the script divides it by the total pixel count of the canvas.
The Python script check.py validates TSV header formatting, enforces turn uniqueness, checks numerical consistency, and fails if that ratio exceeds a tolerance threshold (default 2.0%, an arbitrary default for this guide, not an official limit). Because the denominator is the whole canvas, the ratio understates the change outside the target when the edited region is large.
#!/usr/bin/env python3"""usage: check.py <diff_log.tsv> [max_drift_pct] — verify drift outside target region"""import sys HEADER = ["turn", "target", "total_px", "changed_px", "outside_px"]lines = [l.strip().split("\t") for l in open(sys.argv[1], encoding="utf-8") if l.strip()]limit = float(sys.argv[2]) if len(sys.argv) > 2 else 2.0if not lines or lines[0] != HEADER or len(lines) < 2: print("ERROR: invalid header or empty log"); sys.exit(1)seen, bad = set(), 0for idx, row in enumerate(lines[1:], 2): if len(row) != 5: print(f"FAIL line {idx}: column count {len(row)} != 5"); bad += 1; continue t, name, tot, chg, out = row if not (t.isdigit() and tot.isdigit() and chg.isdigit() and out.isdigit()) or t in seen: print(f"FAIL line {idx}: format error or duplicate turn {t!r}"); bad += 1; continue seen.add(t) tot_n, chg_n, out_n = int(tot), int(chg), int(out) if tot_n <= 0 or chg_n > tot_n or out_n > chg_n: print(f"FAIL line {idx} (turn {t}): inconsistent pixel counts"); bad += 1; continue pct = (out_n / tot_n) * 100.0 flag = "OK " if pct <= limit else "FAIL" if flag == "FAIL": bad += 1 print(f"{flag} line {idx} (turn {t}, {name}): changed {chg_n} px, drift {out_n} px ({pct:.2f}%)")print(f"\n{len(lines)-1} turns checked, {bad} errors")sys.exit(1 if bad else 0)[5] Run the verification script. Check the 3-turn log diff_log.tsv generated from Method B.
$ python3 check.py diff_log.tsv 2.0OK line 2 (turn 1, sofa): changed 152400 px, drift 1820 px (0.09%)OK line 3 (turn 2, window): changed 284500 px, drift 2150 px (0.10%)OK line 4 (turn 3, cat): changed 78900 px, drift 980 px (0.05%) 3 turns checked, 0 errorsAll three turns in the example log stay at or below 0.10%, so the exit code is 0.
Test the validator against diff_log_bad.tsv, where omission of the preservation clause during Turn 2 triggered wall and lighting shifts (this is a synthetic test case, not model output).
$ python3 check.py diff_log_bad.tsv 2.0OK line 2 (turn 1, sofa): changed 152400 px, drift 1820 px (0.09%)FAIL line 3 (turn 2, window): changed 890000 px, drift 512000 px (24.69%)OK line 4 (turn 3, cat): changed 78900 px, drift 980 px (0.05%) 3 turns checked, 1 errorsThe script flags the 24.69% on Turn 2 and exits with code 1. Three intentional test inputs (excessive drift, duplicate turn index, and outside count exceeding changed count) were tested and correctly rejected.
[6] Two checks to build into the prompt when editing one element at a time. These are points considered while designing the prompts, not observations from generated images:
- Ambiguous spatial references: In scenes with multiple windows, specifying "enlarge the window" leaves it undecided which window is meant. Solution: Add directional qualifiers such as "the horizontal window on the left wall".
- Reflection and contact shadow mismatch: When changing the sofa color to olive green, check whether navy reflections remain on the hardwood flooring. Solution: Add an explicit clause: "Update the subtle floor reflection to match the green sofa while keeping the wood grain and floor planks identical".
Avoid using incremental multi-turn prompts for radical perspective shifts or day-to-night lighting inversions. Major structural overhauls warrant starting fresh from an initial generation prompt in a new conversation.