Sub topic 9
Text, Logos, and Why to Add Them Afterwards
This chapter assumes you can write a basic image prompt, you know what a creative brief is, and you are comfortable with introductory Python. You should also know what resolution and file formats are.
Why generators struggle with text
Image generators build pictures from visual patterns. They do not spell. A word in an image is a shape the model approximates, so letters can come out swapped, doubled, or invented. Logos have the same problem. The model has never seen your exact logo, so it produces something that resembles a logo, and a near-match can be worse than none at all.
Common defects include:
- Misspelled or nonsense words on signs, packaging, and shirts.
- Warped or inconsistent letterforms.
- Fake logos that look like real brands, which creates legal risk.
- Text that is correct in one generation and broken in the next.
Some newer tools render short text well. Treat that as a bonus you check, not something to build a campaign on.
The reliable workflow
Generate the picture without text, then add text and logos in a design tool or in code. This gives you exact spelling, your real fonts and brand colors, and the ability to change copy without regenerating the image.
Plan the space in the prompt
Ask for room where the text will go, and exclude text from the generation. The brief's must_include and must_avoid fields already hold these requirements.
prompt = (
"A runner on a forest trail at sunrise, clean photography, soft warm light. "
"Composition: runner in the lower right, empty sky across the top third "
"for a headline. "
"Do not include: text, letters, logos, watermarks."
)
print(prompt)Add the headline and logo with Pillow
This script places a headline in the empty area and a logo in the corner. It assumes you have a font file, a transparent PNG logo, and a generated image. Adjust the paths to your files.
from PIL import Image, ImageDraw, ImageFont
def add_overlay(image_path, logo_path, font_path, headline, out_path):
with Image.open(image_path) as base:
base = base.convert("RGBA")
draw = ImageDraw.Draw(base)
font = ImageFont.truetype(font_path, size=base.width // 12)
draw.text(
(base.width * 0.06, base.height * 0.06),
headline,
font=font,
fill="#FFFFFF",
stroke_width=2,
stroke_fill="#0B3D91",
)
with Image.open(logo_path) as logo:
logo = logo.convert("RGBA")
logo.thumbnail((base.width // 5, base.height // 5))
margin = base.width // 30
position = (base.width - logo.width - margin, base.height - logo.height - margin)
base.alpha_composite(logo, dest=position)
base.convert("RGB").save(out_path, quality=92)
add_overlay(
"runner_hero.png",
"logo.png",
"fonts/Inter-Bold.ttf",
"Spring trail season starts now",
"runner_final.jpg",
)The outline (stroke_width) keeps the text readable on uneven backgrounds. Sizes are relative to the image width, so the same code works for each channel size.
Order matters with resizing
Overlay after you crop to the final aspect ratio, not before. A center crop can cut off text placed near an edge. Keep text inside a safe margin of about 5 to 10 percent from each edge, since some platforms cover the top and bottom of stories with interface elements.
Common mistakes
- Accepting a generated "logo" instead of using your real file.
- Checking spelling only in the first variant. Check every exported size.
- Placing text over a busy area, which hurts legibility.
- Using fonts you are not licensed to use.
Exercise
Why should you ask the generator to leave empty space and exclude text, instead of asking it to write your headline?
Show answer
Generators approximate letter shapes and often misspell or distort words. Adding the headline afterwards gives exact spelling, your brand font and colors, and easy copy changes without regenerating. Reserving empty space in the composition makes room for it.
Exercise
In the Pillow script, why is the logo size set with thumbnail((base.width // 5, base.height // 5)) and not a fixed pixel size?
Show answer
Sizing relative to the image keeps the logo in proportion for every channel size, from 1200x628 link ads to 1080x1920 stories, and thumbnail preserves the logo's aspect ratio.