Place your own logo on a mug mockup without distortion
A prompt for putting a finished logo on a mug mockup, plus a script that compares the cropped logo with the original in blob count, ratio, color and shape.
You asked for your finished logo on a mug mockup and the picture looks fine, but you cannot tell by eye whether the logo is really unchanged. Whether a stroke got thicker, the orange got muddy or one letter changed only shows when you measure it next to the original. The example is an invented two-color logo, "KITE" (navy #1A365D, orange #DD6B20, 1.5:1). The post designs the prompt and adds a script that compares the mockup with the original.
[1] A short prompt says nothing about how the logo should be treated.
A white ceramic mug with my attached logo printed on the front, studio lighting.Google's image generation guide shows the approach of giving a reference image, as in its example of putting a logo into an ad, and telling the model to integrate it into the scene. OpenAI's image generation guide lists as a limitation that it can be hard to keep brand elements visually consistent across several generations. So the second prompt attaches the logo file and also separates what must not change (shapes, proportions, stroke thickness, colors, letters) from what may (the curve of the mug).
Use the attached logo image exactly as it is and place it on a mockup. Scene: a plain white ceramic mug, handle on the right, on a light oak desk, soft daylight from the left.Placement: the logo printed on the front of the mug, centered, about 40% of the mug's width. Keep the logo unchanged:- Do not redraw it. Same shapes, same proportions (1.5 : 1), same stroke thickness.- Same colors: navy #1A365D and orange #DD6B20. They may be shaded only the way a printed surface is shaded.- Same letters: K I T E, with nothing added or removed.- The only change allowed is the curve of the mug's surface.[2] When the result arrives, crop just the logo as a rectangle and save it, leaving only white margin around it so that no handle or desk is inside. Give run/logo_fidelity_en.py the original file and the crop. It finds the blobs that differ from the background, pairs them one-to-one with the original and counts four things. Whether the blob count matches (KITE is one kite shape and four letters). Whether the overall aspect ratio is 85-105% of the original (the mug's curve narrows the width, so stretching past 105% and squashing below 85% are rejected). Whether each blob's median color is within 45 of the original. Whether each blob's shape overlaps the original by at least 0.85. The verdict part:
…orig, ar0 = analyse(sys.argv[1]); mock, ar1 = analyse(sys.argv[2])fails = []ok = len(orig) == len(mock)print(f"blobs {len(orig)} → {len(mock)} {'OK' if ok else 'FAIL'}")if not ok: fails.append("blob count")ratio = ar1 / ar0ok = 0.85 <= ratio <= 1.05print(f"aspect ratio {ar0:.2f} → {ar1:.2f} ({ratio:.0%} of the original, must be 85-105%) {'OK' if ok else 'FAIL'}")if not ok: fails.append("aspect")if len(orig) == len(mock): left = list(mock) for i, a in enumerate(sorted(orig, key=lambda b: b["rel"]), 1): b = min(left, key=lambda m: math.dist(m["rel"], a["rel"])); left.remove(b) dc, s = math.dist(a["color"], b["color"]), iou(a, b) ok = dc <= 45 and s >= 0.85 print(f" blob {i}: color distance {dc:.0f} (45 or less) · shape overlap {s:.2f} (0.85 or more) {'OK' if ok else 'FAIL'}") if not ok: fails.append(f"blob {i}")print("verdict: " + ("pass" if not fails else "fail (" + ", ".join(fails) + ")"))sys.exit(1 if fails else 0)[3] There was no real AI mockup yet, so it was run on seven test images made with Pillow (run/make_fixtures.py; they are not AI output). First a good concept, squeezed to 92% in width and darkened 10% toward the edges as a mug front would be:
$ python run/logo_fidelity_en.py run/logo_original.png run/mock_ok.pngblobs 5 → 5 OKaspect ratio 1.41 → 1.30 (92% of the original, must be 85-105%) OK blob 1: color distance 5 (45 or less) · shape overlap 0.97 (0.85 or more) OK blob 2: color distance 2 (45 or less) · shape overlap 1.00 (0.85 or more) OK blob 3: color distance 2 (45 or less) · shape overlap 0.97 (0.85 or more) OK blob 4: color distance 2 (45 or less) · shape overlap 0.96 (0.85 or more) OK blob 5: color distance 4 (45 or less) · shape overlap 1.00 (0.85 or more) OKverdict: passThe one with the kite turned green:
$ python run/logo_fidelity_en.py run/logo_original.png run/mock_color.pngblobs 5 → 5 OKaspect ratio 1.41 → 1.30 (92% of the original, must be 85-105%) OK blob 1: color distance 5 (45 or less) · shape overlap 0.97 (0.85 or more) OK blob 2: color distance 2 (45 or less) · shape overlap 1.00 (0.85 or more) OK blob 3: color distance 217 (45 or less) · shape overlap 0.97 (0.85 or more) FAIL blob 4: color distance 2 (45 or less) · shape overlap 0.96 (0.85 or more) OK blob 5: color distance 4 (45 or less) · shape overlap 1.00 (0.85 or more) OKverdict: fail (blob 3)All seven. mock_text has the bottom bar of the E erased so it reads F, and mock_blur has soft edges.
$ python run/fidelity_report.py enmock_aspect.png: verdict: fail (aspect)mock_blur.png: verdict: fail (blob 1, blob 2, blob 3, blob 4, blob 5)mock_color.png: verdict: fail (blob 3)mock_ok.png: verdict: passmock_stroke.png: verdict: fail (blob 1)mock_stroke_light.png: verdict: passmock_text.png: verdict: fail (blob 5)[4] The test also showed where the checker stops catching things. mock_stroke_light, with strokes 2px thicker on each side, passed. mock_stroke, 4px thicker on each side, was caught on only 1 of 5 blobs (the other four overlapped by 0.86 to 1.00, above the 0.85 line). The overlap for mock_text, E turned into F, was 0.77, close to the line. A swap to a letter of similar shape cannot be judged from this test. So read the letters by enlarging the crop and spelling out K I T E, and judge stroke thickness by laying the crop over the original at the same scale.
[5] How real AI mockups go wrong was not tested in this run. What to look at in a result:
| Look at | Where |
|---|---|
| Number and spelling of letters | Read them by eye (the blob count in the script is a helper) |
| Proportions | The aspect ratio line of the script |
| Colors | The color distance line (shading from the lighting is allowed up to 45) |
| Stroke thickness | The script catches large changes only; overlay the two |
| Gloss passing over the letters | By eye (this script was not tested for it) |
For a proof that goes to a printer, or a deliverable bound by brand rules, it is safer not to use a logo that the AI composited. Use the model for the empty-mug photo only and place the original logo file in a design tool (a suggestion, not something this post tested).