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.

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.
| Check | How |
|---|---|
| Dimensions equal source | Pillow assert above |
| New text exact | Read it against the approved copy |
| Everything else unchanged | Flip between source and result |
| Edges and logo intact | View at 100 percent |
| Right file for the market | Name 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
- Text to speech from a PDF with an API: extract, chunk, narrate
Sume's TTS takes text, not PDF files. Extract the text, split it under 20,000 characters, narrate each chunk, then join the audio. Costs and limits included.
- Thanksgiving recipe video: step cards with caption cues
Make a 40-second Thanksgiving recipe video from five phone shots: join them in Timeline 1.0, burn numbered step cards with caption cues, add a music bed.
- TikTok's reported 24 hours to disclose or appeal, and a burned-in fix
A brand-agency summary reports TikTok gives 24 hours to add a disclosure or appeal. A plan for that day, and a Sume captions call that burns the line in.
- TikTok 90-day violation window: a label ledger for AI batches
If a summary's 90-day violation window is right, one unlabeled batch can cost a posting ban. Build a per-clip ledger from Sume job ids before you post.
Written by Sume