|
@@ -0,0 +1,67 @@
|
|
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
|
|
+"""
|
|
|
|
|
+demo_shoe_compose.py —— shoe_main_image_compose 的演示/验证脚本
|
|
|
|
|
+
|
|
|
|
|
+1. 按实测裁剪框从 ref_b.png(图1,目标效果图)直接裁出 logo 与 5 只鞋,
|
|
|
|
|
+ 生成测试素材(python/output/demo_shoe_assets/)。
|
|
|
|
|
+ 不做抠图 —— 实际使用时传入的鞋子图本身就是透明底 PNG,
|
|
|
|
|
+ compose_shoe_main_image 会先按 alpha 裁切最小边再合成。
|
|
|
|
|
+2. 以 ref_a.png(图2,底图模板)为底,分别按 5 款 / 1 款 / 7 款 数量
|
|
|
|
|
+ 调用 compose_shoe_main_image 合成,验证等分布局。
|
|
|
|
|
+
|
|
|
|
|
+运行: python demo_shoe_compose.py
|
|
|
|
|
+"""
|
|
|
|
|
+
|
|
|
|
|
+from service.shoe_main_image_compose import compose_shoe_main_image # noqa: E402
|
|
|
|
|
+
|
|
|
|
|
+REF_TPL = "resources/detail_temp/scene/tpl_1.png" # 图2:底图模板
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# 图1 中各素材的裁剪框 (x1, y1, x2, y2),按像素测量的最小边。
|
|
|
|
|
+# x2 统一取 136:刚好在浅色区与粉色布景交界处左侧,裁出的素材不含布景条纹。
|
|
|
|
|
+
|
|
|
|
|
+def main():
|
|
|
|
|
+ logo = "output/demo_shoe_assets/logo.png"
|
|
|
|
|
+ items = {
|
|
|
|
|
+ "logo": logo,
|
|
|
|
|
+ "number_mid": {"name": "货号(中童)", "value": "1025B-17"},
|
|
|
|
|
+ "size_mid": {"name": "尺码 Size", "value": "24-29#"},
|
|
|
|
|
+ "number_big": {"name": "货号(大童)", "value": "1025A-17"},
|
|
|
|
|
+ "size_big": {"name": "尺码 Size", "value": "30-35#"},
|
|
|
|
|
+ "box": {"name": "装箱 Box", "value": "60双"},
|
|
|
|
|
+ "image_path": pil,
|
|
|
|
|
+ "images": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "image_path": pil,
|
|
|
|
|
+ "color": "米白",
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "image_path": pil,
|
|
|
|
|
+ "color": "粉色",
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "image_path": pil,
|
|
|
|
|
+ "color": "卡其",
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "image_path": pil,
|
|
|
|
|
+ "color": "蓝色",
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ result_url = compose_shoe_main_image(template=REF_TPL,
|
|
|
|
|
+ data=items,
|
|
|
|
|
+ label_pos="right",
|
|
|
|
|
+ shoe_scale=0.9,
|
|
|
|
|
+ font_path="resources/ttl/MiSans-Light.ttf",
|
|
|
|
|
+ upload=True,
|
|
|
|
|
+ info_bottom_margin=20,
|
|
|
|
|
+ label_font_size=30,
|
|
|
|
|
+ info_bar_height=40,
|
|
|
|
|
+ info_font_size=34)
|
|
|
|
|
+ print("合成完成,输出:", result_url)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+if __name__ == "__main__":
|
|
|
|
|
+ main()
|