GrepBoard/Manuals
605 manuals ·

Fix garbled Korean text inside an AI-generated product banner

·Tested on Gemini official image prompt guide · 2026-10·Test scope ↓·6 steps

Structure image prompts to prevent broken Korean text in product banners by limiting characters, and verify the rendered output with a character-level script.

When generating promotional banners for e-commerce product pages with phrases like "당일발송 무료배송", diffusion models frequently drop final consonants or produce distorted, illegible Korean glyphs.

The Google Cloud Vertex AI image prompt guide specifies limiting text to 25 characters or fewer per block and keeping layouts to three phrases or fewer. The Gemini image generation documentation instructs enclosing exact text strings in quotation marks and explicitly defining font characteristics alongside high background contrast.

[1] Inspect the failure pattern of unstructured natural language requests. Submitting vague prompts like "add promotional text to the banner" gives the model no conditions beyond the phrase itself.

Korean syllables combine initial consonants, medial vowels, and optional final consonants (batchim), so a single dropped batchim turns one syllable into another ("ㅇ" in "송", "ㄹ" in "발"). No images were generated for this guide, so what this prompt actually renders was not tested.

text
Create an e-commerce promotional banner for electronics. Make it orange and write '오늘 출발 무료배송' in large letters.

This prompt says nothing about typography, the surface the text sits on, or contrast. The template below fills in those conditions.

[2] Construct a structured text-locking prompt template. To reduce spelling errors, place the target phrase inside double quotation marks and specify an isolated, solid-color label container. Specify clean, bold sans-serif typography.

text
An e-commerce promotional top banner for {product_category}.Clean studio background, product photography on the left.A solid {label_background_color} rectangular label plate on the center-right.Inside the container, render exactly this text in bold Korean sans-serif typography: "{display_text}".Rules:- Text string: "{display_text}"- Font style: Clean bold gothic sans-serif font- Color: {text_color} text on {label_background_color} background for contrast- Placement: Centered inside the label container- No other text, no misspelled glyphs, no decorative script.

[3] Choose a layout by phrase length. The official guide sets only two limits: 25 characters or fewer, and three phrases or fewer. The character counts below use the same counting as check.py (spaces included), and the layouts are this guide's own suggestions, not official tiers or measured results.

Example textCharacters (spaces included)Suggested layout
당일발송 무료배송9One label plate, centered
신규회원 첫구매 15% 할인쿠폰17Split into 2 lines and state the line break in the prompt
주문 즉시 산지 직송 프리미엄 신선 안심 보장25At most 3 phrases, one label plate per phrase
24시간 이내 당일 출고 프리미엄 신선 냉장 포장 무료배송 이벤트36Over the guide's 25 characters, so keep it out of the image and overlay the text separately

[4] Write the verification script check.py. Compare OCR-extracted or manually transcribed text against the expected string character by character. Use standard Unicode decomposition to isolate Korean syllable components and detect dropped final consonants.

run/check_en.py
#!/usr/bin/env python3"""usage: check.py target.txt ocr.txt - missing final consonant (batchim) and 25-character check"""import sys def decomp(c):    if 0xAC00 <= ord(c) <= 0xD7A3:        i = ord(c) - 0xAC00        cho = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ"[i // 588]        jung = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ"[(i % 588) // 28]        jong = ["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][i % 28]        return cho, jung, jong    return c, "", "" t = open(sys.argv[1], encoding="utf-8").read().strip()o = open(sys.argv[2], encoding="utf-8").read().strip()print(f"Target: {t!r} ({len(t)} chars)\nRendered: {o!r} ({len(o)} chars)")errs = [f"TARGET_TOO_LONG: {len(t)} > 25 chars"] if len(t) > 25 else [] for i in range(max(len(t), len(o))):    tc = t[i] if i < len(t) else ""    oc = o[i] if i < len(o) else ""    if tc != oc:        if tc and oc and (0xAC00 <= ord(tc) <= 0xD7A3):            t_cho, t_jung, t_jong = decomp(tc)            o_cho, o_jung, o_jong = decomp(oc)            if t_cho == o_cho and t_jung == o_jung and t_jong and not o_jong:                errs.append(f"POS {i}: MISSING_BATCHIM (expected '{t_jong}', got none)")                continue        errs.append(f"POS {i}: MISMATCH ('{tc}' vs '{oc}')") print(f"\nResult: {len(errs)} issues found")for e in errs:    print(f"  - {e}")sys.exit(1 if errs else 0)

[5] Execute the verification script against test inputs. Run the script by passing the target file and the recognized text file as positional arguments. Exact matches pass with exit code 0. The comparison is position by position, so one inserted or missing character shifts everything after it and the later characters all show up as mismatches (see the test output below).

console
$ python3 run/check_en.py run/target_en.txt run/sample_ocr_en_ok.txtTarget: 'Free Same-Day Delivery' (22 chars)Rendered: 'Free Same-Day Delivery' (22 chars) Result: 0 issues found

Test whether the script flags spelling discrepancies and dropped letters. The failure output below was generated using sample_ocr_en_bad.txt with an intentional typographical error (not generated by the model).

console
$ python3 run/check_en.py run/target_en.txt run/sample_ocr_en_bad.txtTarget: 'Free Same-Day Delivery' (22 chars)Rendered: 'Free Same-Day Delvery' (21 chars) Result: 5 issues found  - POS 17: MISMATCH ('i' vs 'v')  - POS 18: MISMATCH ('v' vs 'e')  - POS 19: MISMATCH ('e' vs 'r')  - POS 20: MISMATCH ('r' vs 'y')  - POS 21: MISMATCH ('y' vs '')

The 25-character check measures the first argument (the expected-text file), so the long text must go there. python3 run/check_en.py run/target_en_long.txt run/sample_ocr_en_long.txt printed TARGET_TOO_LONG: 68 > 25 chars and exited with code 1. With the short target_en.txt as the first argument and only the long OCR file as the second, that error does not appear; only position mismatches do.

[6] Review common failure causes and apply fallback workflows. These are checks derived from the official guidance. No images were generated in this run, so none of them was tested.

  • Avoid script and decorative fonts: Avoid handwriting or calligraphic styles and keep the typeface simple. Use bold sans-serif or clean geometric gothic font.
  • Avoid complex compound consonants: Double batchim syllables like ㄳ, ㄵ, ㄶ, ㄺ, ㄻ, ㄼ, ㄽ, ㄾ, ㄿ, ㅀ, ㅄ, ㅆ deserve a closer check of the result. You can swap in words with simpler final consonants, but this run did not test which version renders better.
  • Maintain high contrast on label plates: If the text color is close to the background, the text can blend into objects behind it, so specify contrast as the official guidance says. Place a solid white or charcoal-gray box behind the text area.
  • Decide when to decouple rendering: For banners exceeding 25 characters or containing brand trademarks where zero typographical error is tolerated, omit text generation entirely. Append empty label plate, no text to the prompt, and overlay text using front-end HTML/CSS or graphics editors.

For maintaining visual consistency across generated assets, see maintain consistent characters in AI images.

#banner#gemini#image-prompt#korean-text