Joffoo's blog

The ethereal flight, oft rehearsed in the theater of one's dreams...

保管时间:Google AI Studio 自制电影票根

在所有打发时间的方式里,看电影无疑是最不划算的一种。同样的钱,拿来买书能读上一个礼拜,买酒也够喝上一整晚了。一张电影票却只能消磨一两个小时,而且是身处一间黑屋子、困坐在一张小椅子上的一两个小时。——《悲悼》

电影,我看得不多。

但现在还能想起来,儿时的我会把去影院看过的电影名字记录在一个 Word 文档里,用一些花哨的艺术字。

回想起来,电影也不是什么好电影,但是把片名列在一起的那个 .doc 文件,确实带给我一种莫名的安全感,像是给刚刚支付出去的一两个小时开了张收据。

虽然,这个文档已经不见了……新版 Word 的艺术字也内敛了许多。

简单实现

前段时间领取了一个月的 Gemini Enterprise,可以比较任性地使用 Nano Banana Pro。我确实找到了不少提示词,试一试、改一改、再试一试。固然有趣,但像是一种消耗精力的娱乐,不断冲洗大脑皮层。

于是,我尝试做点小东西。

正好下午刚看了场电影,于是我灵机一动(和 AI 聊了不下十轮并让它)写下了这段提示词:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
"system_directive": {
"role": "Senior Visual Designer",
"task": "Generative_Ticket_Design",
"mode": "Style_Transfer_and_Layout"
},
"global_config": {
"aspect_ratio": "9:16",
"render_quality": "High Fidelity, Vector Style"
},
"input_payload": {
"source_reference": "<UPLOAD_POSTER_IMAGE>",
"text_data": {
"movie_en": "Resurrection",
"movie_cn": "狂野时代",
"time_val": "2025.12.07 12:10",
"location_val": "VIP厅, 红星电影世界(天津之眼店)",
"price_val": "¥34.90"
}
},
"visual_processing_rules": {
"art_direction": {
"style_preset": "Swiss International Style (Grid-based, Minimalist)",
"image_treatment": "RE-RENDER logic: Do NOT copy-paste the source. Analyze the source poster's composition and color, then re-draw it as a clean, flat Vector Illustration or Stylized Digital Art to fit the ticket aesthetic.",
"canvas_logic": "The Output Image IS the ticket. Full bleed. No background borders."
},
"layout_engine": {
"structure": "Vertical Split based on {aspect_ratio}. Top 60% = Artwork. Bottom 40% = White Info Panel.",
"info_panel_hierarchy": "1. Movie Title (Top of white area). 2. Data Grid (Bottom of white area). 3. Barcode (Bottom edge).",
"decoration": "Vertical BARCODE strip in the corner."
},
"typography_logic": {
"font_family": "DIN 1451 or Helvetica Neue (Bold)",
"title_handling": {
"primary_visual": "Render {movie_en} in LARGE, UPPERCASE, BOLD typography. This is the main design anchor.",
"secondary_visual": "Render {movie_cn} in a smaller, readable font size, placed elegantly next to or below the English title."
},
"data_mapping": {
"location_field": "Render {location_val}. Auto-wrap text if too long.",
"time_field": "Render {time_val} clearly.",
"price_field": "Render {price_val}."
}
}
},
"output_constraint": "Single graphic file. Flat 2D view. Strict split layout. No gibberish text."
}

"text_data" 这部分可以自行填写,然后把填充好的提示词,以及凭自己喜好选的一张海报,一起丢给 Nano Banana Pro,会得到类似于这样的效果:

你可以尝试多次,最终得到一个满意的样式。

作为系列设计,当然需要复用同样的版式。所以在生产后续图像时,可以把第一张满意的结果作为第二张参考图片。

微调上面的提示词:

1
2
3
4
5
6
7
8
9
10
11
"input_payload": {
"source_reference": "Figure 1",
"layout_reference": "Figure 2",
"text_data": {
"movie_en": "The Stage",
"movie_cn": "戏台",
"time_val": "2025.07.20 16:40",
"location_val": "1号厅, 中和影城(南开劝业场店)",
"price_val": "¥30.30"
}
},

这时,把电影海报作为图 1,把第一张票根作为图 2,连同调整后的提示词,一起丢给 Nano Banana Pro,会得到这样的效果:

基本令人满意。

稳固实现

那就是还不满意。

回看前面 JSON 格式的提示词,总让人感觉是一段程序,貌似是可以稳定产出成品的。但事与愿违,生图模型还是会自行发挥。

虽然你可以反过来想,如果生图模型每次都可以给出你钟意的刻板结果,那它的审美可见——一般。

总之,我希望文字部分是固定的,而图片部分可以“创意”一些。很自然能想到 Google AI Studio 的 Build 模式,一来可以用 Gemini 3.0 Pro 写代码,二来可以让所写的程序调用图片编辑模型(是 Nano Banana,而非 Pro 模型,但因为不涉及汉字的生成,还是够用的)。

大体思路如下:

  1. 把上一节的 JSON 提示词发给 AI,告诉它我需要一个网页,用户要填写哪些信息,并且上传海报,调用图像编辑模型完成转绘,转绘后的图像比例固定为 1:1,防止遮挡;
  2. 上传满意的文字信息样式,让 AI 进行复刻(如果你死抠细节的话,还是需要多轮修改才行,我就调节了很久条形码的样式,虽然这部分只是随机数生成的结果);
  3. 小功能的实现,比如:剪贴板上传图片、直接从 HTML 生成图片(注意要先等所有字体文件下载完毕)、文本框换行,以及模式切换(影院观影和居家观影)。

项目地址为 SwissStyle Ticket Generator,因为需要调用 Nano Banana,所以还是直接在 AI Studio 这里用比较方便。

使用方法如下:

效果如下:

图像转绘的提示词是 Gemini 自己写的,我同样附在下面了,如果你有更好的想法也可以自己定制。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SYSTEM ROLE: Senior Visual Designer
TASK: Style Transfer & Re-rendering

INSTRUCTION:
Take the provided source image (poster) and re-draw it completely in the style of "Swiss International Style" (International Typographic Style).

VISUAL RULES:
1. STYLE: Flat Vector Illustration, Minimalist, Grid-based layout.
2. COLORS: High contrast, bold, solid colors.
3. COMPOSITION: Keep the main subject from the source image but simplify it into geometric shapes and clean lines.
4. NO TEXT: The output must be PURE ARTWORK. Do NOT include the movie title, credits, actors' names, or any text from the original poster. The text will be added later programmatically.
5. ASPECT RATIO: 1:1 (Square). The artwork must be perfectly square.

SUBJECT: The movie is "${movieTitle}".

OUTPUT: A single, high-quality image file of the artwork only.

附录

甚至,“网页使用方法”也是用 Nano Banana Pro 生成的,提示词如下:

1
这是一张网页截图,该网页的功能是用户上传海报,然后让AI重绘得到自制电影票根,你需要用Excalidraw工具加上**触控板手写**中文批注、涂鸦,说明网页使用方法,还可以加点小剪贴画。图像为4K清晰度。

文章目录

  1. 简单实现
  2. 稳固实现
  3. 附录

Proudly powered by Hexo and Theme by Hacker
© 2026 Fengyukongzhou