Text edited in an ad image: a dimension check before you ship

After an AI text replacement, compare output and source dimensions in Pillow. Stretched or recropped edits are caught in one assert, before the ad goes live.

4 min readSume
All posts

After an AI edit that replaces text in an ad image, check three things before it ships: the output has the same pixel dimensions as the source, the aspect ratio matches, and the new text reads correctly. The first two take a few lines of Pillow; the third needs eyes.

Higgsfield lists Ideogram 4.5 reference edits and text replacement that preserve layout (Higgsfield changelog, read 2026-10-02). Whatever model runs the edit, verify the claim on your own file.

Why can an edit change the shape?

Sume's Image API docs say that on edit and image-to-image calls you should prefer aspect_ratio: "auto" to match the reference, and that omitting the field is not the same as auto. An edit sent without it can come back in a different shape from the source.

How do I check dimensions in Python?

Download the source and the result, open both with Pillow, and compare. Allow a tiny tolerance only if your pipeline resizes on purpose; otherwise assert equality.

from PIL import Image


def check_edit(source_path: str, result_path: str) -> None:
    src = Image.open(source_path)
    out = Image.open(result_path)
    if src.size != out.size:
        raise SystemExit(f"size changed: {src.size} -> {out.size}")
    src_ratio = src.width / src.height
    out_ratio = out.width / out.height
    if abs(src_ratio - out_ratio) > 0.001:
        raise SystemExit("aspect ratio changed")
    print("dimensions ok", out.size)


check_edit("banner-us.png", "banner-de.png")

What else belongs on the checklist?

Dimensions are the machine check. The rest is a short human pass per market.

Pre-ship checklist, read 2026-10-02
CheckHow
Dimensions equal sourcePillow assert above
New text exactRead it against the approved copy
Everything else unchangedFlip between source and result
Edges and logo intactView at 100 percent
Right file for the marketName files by market code

What if a check fails?

Resend the edit with aspect_ratio: "auto", a prompt that names the exact old and new text, and the words "change nothing else". If a small region keeps drifting, a masked edit with mask_url limits the change to that region on ChatGPT Image 2.5. The request fields are in the Image API docs.

Sources

Related posts

More in Use cases

All Use cases posts

Written by Sume