Price labels on AI product photos: draw the text in code

AI image models can misplace text, per OpenAI's own guide. For exact prices, generate a clean product photo on Sume and add the label with Pillow instead.

4 min readSume
All posts

If the price has to be right, set it in code. OpenAI's image guide (read 2026-10-06) says its models can still struggle with precise text placement and clarity. A price is the worst place to find out: a wrong digit on a product photo is a pricing error you have published.

The safe split is to let the model make the picture and let your code write the number.

Ask for space, not for the label

Prompt for the product on a plain background with clear empty room in one corner, and do not mention a price at all. On Sume that is one POST /v1/images call. Then open the file and draw the label yourself, so every digit comes from your catalog data.

import sys
from PIL import Image, ImageDraw, ImageFont

def label(src: str, dst: str, text: str) -> None:
    im = Image.open(src).convert("RGB")
    draw = ImageDraw.Draw(im)
    font = ImageFont.load_default(size=max(24, im.height // 14))
    x, y = im.width // 20, im.height // 20
    left, top, right, bottom = draw.textbbox((x, y), text, font=font)
    draw.rectangle((left - 12, top - 8, right + 12, bottom + 8), fill=(255, 255, 255))
    draw.text((x, y), text, font=font, fill=(20, 20, 20))
    im.save(dst)

if __name__ == "__main__":
    if len(sys.argv) != 4:
        raise SystemExit("usage: label.py SRC DST TEXT")
    label(*sys.argv[1:])

What goes where

Text in product images: model versus code, from docs read 2026-10-06
TextLet the model draw it?Reason
Price, discount, SKUNoA wrong character is a factual error
Short slogan on a posterMaybe, then verifyVendors claim legible text but warn about placement
Text printed on the product itselfYes, and check itIt is part of the object, not an overlay
Alt text for the finished imageNo, write itW3C: put text from the image in the alt if it is not on the page

Habits that save time

  • Overlay in code, so you never regenerate the picture just to fix a number.
  • Keep the price in your data, not in the file name or the prompt.
  • Use one font file across the shop so labels look the same on every product.
  • Save the clean photo as well as the labeled one. A price change then costs a script run, not a generation.

Sources

Related posts

More in Use cases

All Use cases posts

Written by Sume