DEV Community

Cover image for A Simple Prompt Framework for AI Image Editing
AI iWeaver
AI iWeaver

Posted on

A Simple Prompt Framework for AI Image Editing

Most AI image editing tutorials focus on the tool.

I think the prompt matters just as much.

When editing an existing image with AI, a vague instruction like:

Make this better.

gives the model too much freedom.

A more reliable approach is to define the edit as a small transformation.

The Prompt Framework

I've found this structure useful:

Target + Change + Preservation + Visual Constraints

For example:

Target: background

Change: replace it with a modern office

Preservation: keep the person and clothing unchanged

Constraints: maintain the original perspective and realistic lighting

Turn that into a natural prompt:

Replace the background with a modern office. Keep the person, face, clothing, pose, and camera angle unchanged. Match the original lighting and shadows.

This works for many common editing tasks.

Example: Replace an Object

Suppose you have a lifestyle photo where someone is holding a coffee mug.

You want a glass bottle instead.

A weak prompt would be:

Replace the mug.

A better one:

Replace the coffee mug in the person's right hand with a transparent glass water bottle. Keep the hand position, person, background, composition, and lighting unchanged.

The important part is not just telling the model what to generate.

You're also telling it what not to regenerate.

Example: Change Clothing

The same framework works for clothes:

Replace the blue T-shirt with a black leather jacket. Keep the person's face, body, pose, hairstyle, background, and lighting unchanged.

This is much more controlled than asking the model to "give this person a new outfit."

Example: Change Hair Color

For smaller edits:

Change the hair color from black to copper red. Preserve the hairstyle, face, skin tone, clothing, background, and lighting.

Again, the preservation instructions matter.

Testing the Workflow

I've been experimenting with this approach using XPT, which supports prompt-based image editing.

Instead of manually working with selections and layers, the workflow is basically:

  1. Upload the original image.
  2. Describe the target edit.
  3. Specify what must remain unchanged.
  4. Generate.
  5. Adjust the prompt and retry if needed.

For simple edits, this is much faster than opening a traditional editor.

A Reusable Template

Here's the basic template I use:

Change [TARGET] from [CURRENT STATE] to [DESIRED STATE]. Keep [PRESERVED ELEMENTS] unchanged. Maintain the original [LIGHTING / PERSPECTIVE / COMPOSITION / STYLE].

For example:

Change the white wall behind the subject into a large window overlooking Tokyo at night. Keep the subject, face, clothing, pose, furniture, and camera angle unchanged. Maintain realistic lighting and reflections.

Final Thought

AI image editing is increasingly becoming an instruction problem rather than a manual editing problem.

The model can handle much of the mechanical work.

The user's job is becoming simpler:

Describe the change precisely and define what should stay untouched.

That's a surprisingly useful skill to learn.

Top comments (0)