From fd596776e241c45b6d5f37fa48e4bc7c09b1d8da Mon Sep 17 00:00:00 2001 From: seaislee1209 Date: Wed, 24 Jun 2026 00:56:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(image):=20=E6=94=AF=E6=8C=81=E7=9C=9F=2016?= =?UTF-8?q?:9(1536x864)+=20=E4=BA=BA=E7=89=A9/=E5=95=86=E5=93=81=E4=B8=89?= =?UTF-8?q?=E8=A7=86=E5=9B=BE/=E5=9C=BA=E6=99=AF=E9=BB=98=E8=AE=A4=2016:9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gpt-image-2 实测支持 16:9(宽高需被 16 整除):真 16:9 = 1536x864(长边封顶 1536); 原来「16:9」误给成 1536x1024(实为 3:2)。修正 _RATIO_TO_SIZE 与 _ratio_to_image_size - admin「提示词」页比例按钮新增「宽 16:9」 - 迁移 0015/0016:scene + product_triview + person_triview 默认比例设为 16:9; 分镜图(storyboard_frame)/立绘/视频保持竖屏不动 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../ai/migrations/0015_scene_product_16_9.py | 19 +++++++++++++++++++ .../ai/migrations/0016_person_triview_16_9.py | 18 ++++++++++++++++++ core/backend/apps/ai/services.py | 7 ++++--- .../src/routes/admin/admin-prompts.tsx | 3 ++- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 core/backend/apps/ai/migrations/0015_scene_product_16_9.py create mode 100644 core/backend/apps/ai/migrations/0016_person_triview_16_9.py diff --git a/core/backend/apps/ai/migrations/0015_scene_product_16_9.py b/core/backend/apps/ai/migrations/0015_scene_product_16_9.py new file mode 100644 index 0000000..7dc2755 --- /dev/null +++ b/core/backend/apps/ai/migrations/0015_scene_product_16_9.py @@ -0,0 +1,19 @@ +from django.db import migrations + +# 场景 / 商品三视图 默认比例改 16:9(1536x864);分镜图(storyboard_frame)保持竖屏不动。 +KEYS = ["scene", "product_triview"] + + +def forwards(apps, schema_editor): + apps.get_model("ai", "PromptTemplate").objects.filter(key__in=KEYS).update(ratio="16:9") + + +def backwards(apps, schema_editor): + apps.get_model("ai", "PromptTemplate").objects.filter(key__in=KEYS).update(ratio="landscape") + + +class Migration(migrations.Migration): + + dependencies = [("ai", "0014_video_prompt_dialogue_no_meta")] + + operations = [migrations.RunPython(forwards, backwards)] diff --git a/core/backend/apps/ai/migrations/0016_person_triview_16_9.py b/core/backend/apps/ai/migrations/0016_person_triview_16_9.py new file mode 100644 index 0000000..e742df0 --- /dev/null +++ b/core/backend/apps/ai/migrations/0016_person_triview_16_9.py @@ -0,0 +1,18 @@ +from django.db import migrations + +# 人物三视图 也改 16:9(1536x864)。0015 已处理场景/商品三视图,这里补人物三视图。 + + +def forwards(apps, schema_editor): + apps.get_model("ai", "PromptTemplate").objects.filter(key="person_triview").update(ratio="16:9") + + +def backwards(apps, schema_editor): + apps.get_model("ai", "PromptTemplate").objects.filter(key="person_triview").update(ratio="landscape") + + +class Migration(migrations.Migration): + + dependencies = [("ai", "0015_scene_product_16_9")] + + operations = [migrations.RunPython(forwards, backwards)] diff --git a/core/backend/apps/ai/services.py b/core/backend/apps/ai/services.py index 2823d11..813f277 100644 --- a/core/backend/apps/ai/services.py +++ b/core/backend/apps/ai/services.py @@ -723,13 +723,13 @@ def _find_entity_group(project, kind: str, label: str, group_id: str | None): def _ratio_to_image_size(ratio: str) -> str: - """前端比例(1:1 / 3:4 / 9:16)→ gpt-image 支持的尺寸。竖屏统一 1024x1536,横屏 1536x1024。""" + """前端比例 → gpt-image 支持的尺寸(宽高均需被 16 整除)。16:9 用真 16:9 的 1536x864,4:3 用 1536x1024。""" return { "1:1": "1024x1024", "3:4": "1024x1536", "9:16": "1024x1536", "4:3": "1536x1024", - "16:9": "1536x1024", + "16:9": "1536x864", # 真 16:9(原来误用 1536x1024 = 3:2) }.get((ratio or "").strip(), "1024x1024") @@ -768,7 +768,8 @@ def quality_suffix(stage: str, fallback: str, slot: str = "quality", sep: str = _PROMPT_PLACEHOLDER_RE = re.compile(r"\{(\w+)\}", re.UNICODE) -_RATIO_TO_SIZE = {"1:1": "1024x1024", "portrait": "1024x1536", "landscape": "1536x1024"} +# gpt-image 要求宽高都能被 16 整除;1536x864 = 真 16:9(长边封顶 1536),1536x1024 = 3:2 +_RATIO_TO_SIZE = {"1:1": "1024x1024", "portrait": "1024x1536", "landscape": "1536x1024", "16:9": "1536x864"} def _prompt_template_row(key: str): diff --git a/core/frontend/src/routes/admin/admin-prompts.tsx b/core/frontend/src/routes/admin/admin-prompts.tsx index 2835cdd..dc2d31a 100644 --- a/core/frontend/src/routes/admin/admin-prompts.tsx +++ b/core/frontend/src/routes/admin/admin-prompts.tsx @@ -10,7 +10,8 @@ const RATIOS = [ { key: "", label: "默认" }, { key: "1:1", label: "1:1 方" }, { key: "portrait", label: "竖 2:3" }, - { key: "landscape", label: "横 3:2" } + { key: "landscape", label: "横 3:2" }, + { key: "16:9", label: "宽 16:9" } ]; export function AdminPromptsPage({ notify }: { notify: Notify }) {