Sub topic 5
Setting constraints and excluding unwanted elements
This chapter assumes you can write a creative brief and a basic prompt with subject, style, composition, lighting, and color. It covers how to state limits so the generator stays inside them.
Why constraints matter
A prompt says what you want. A constraint says what the image must or must not contain. Marketing images carry risks that art images don't: stray text, logos that look like a competitor's, faces of people who might be real, and layouts that leave no room for a headline. Your brief already lists these under must_include and must_avoid. This chapter turns those lists into prompt language.
Two kinds of constraints
- Positive constraints describe a required feature in the image, such as "empty space at the top for a headline" or "morning light".
- Exclusions name things to leave out, such as "text, logos, people".
Positive constraints are more reliable. Many generators handle a negated phrase poorly, because naming an object can pull it into the image. A prompt that says "no people" may still produce people. Where the tool allows it, use these methods in this order:
- Describe the scene so the unwanted element has no reason to appear. "An empty trail at dawn" works better than "a trail, no hikers".
- Use the tool's negative prompt field if it has one. This is a separate input that lists things to avoid, and it is usually more dependable than a "do not" sentence.
- If the tool has neither, add a short "Do not include" line at the end of the prompt, as the code below does.
- Remove the element afterwards with editing, covered in later chapters.
Building constraints from the brief
The brief's fields map directly to prompt text. Keeping them as structured data lets you reuse the same exclusions across every image in a campaign.
BRIEF = {
"subject": "a runner on a forest trail in morning light",
"style": "bright editorial photography",
"must_include": ["trail setting", "morning light", "empty space at the top for a headline"],
"must_avoid": ["readable text", "brand logos", "identifiable real people"],
}
def build_constrained_prompt(brief, use_negative_field):
include = "Required: " + ", ".join(brief["must_include"])
parts = [brief["subject"], brief["style"], include]
avoid = ", ".join(brief["must_avoid"])
if use_negative_field:
return ". ".join(parts) + ".", avoid
parts.append(f"Do not include: {avoid}")
return ". ".join(parts) + ".", None
prompt, negative = build_constrained_prompt(BRIEF, use_negative_field=True)
print("PROMPT:", prompt)
print("NEGATIVE:", negative)
prompt, negative = build_constrained_prompt(BRIEF, use_negative_field=False)
print("PROMPT:", prompt)
print("NEGATIVE:", negative)The function returns a prompt and an optional negative string. The first call sends the exclusions to a separate field. The second folds them into the prompt text for tools that lack one.
Common mistakes
- Too many exclusions. A long avoid list can confuse the model or flatten the image. Keep to the items that matter for this campaign.
- Contradictions. "Busy city street" with "empty space everywhere" gives mixed results. Check that required and excluded items don't conflict.
- Vague limits. "Nothing weird" is not testable. "No readable text, no extra fingers" can be checked.
- Forgetting layout. Space for a headline is a constraint too. State where it goes, such as "left third empty".
- Changing several limits at once. If you add three exclusions and the result worsens, you can't tell which one caused it. Add them one at a time, as the iteration chapter describes.
Exercise
A prompt reads "A cafe interior, no people, no text." The result shows a barista and a menu board with letters. Name two changes you would try, in order.
Show answer
First, rewrite the scene so people and text have no reason to appear, for example "an empty cafe interior before opening, plain walls, blank chalkboard". Second, move "people, readable text" into the tool's negative prompt field, or into a "Do not include" line if there is no such field. If the barista or menu still appears, remove it afterwards with inpainting or editing, and check the final image.