diff --git a/README.md b/README.md index 6649014..f0cf44b 100644 --- a/README.md +++ b/README.md @@ -378,6 +378,10 @@ docker run -d -p 7860:7860 \ - 修改`demo/assets/title.md` +## 5. 如何添加/修改「打印排版」中的尺寸? + +- 修改`demo/locales.py`中的`print_switch`字典,添加/修改新的尺寸名称和尺寸参数,然后重新运行`python app.py` +
# 📧 联系我们 diff --git a/demo/locales.py b/demo/locales.py index b74913c..571d3be 100644 --- a/demo/locales.py +++ b/demo/locales.py @@ -718,6 +718,7 @@ LOCALES = { }, }, "print_switch": { + "shape": [[1205, 1795], [1051, 1500], [2479, 3508], [1051, 1500], [1205, 1795]], "en": { "label": "Paper size", "choices": ["6 inch", "5 inch", "A4", "3R", "4R"], diff --git a/demo/processor.py b/demo/processor.py index 8adab02..1792407 100644 --- a/demo/processor.py +++ b/demo/processor.py @@ -442,20 +442,13 @@ class IDPhotoProcessor: if idphoto_json["size_mode"] in LOCALES["size_mode"][language]["choices"][1]: return None, False - # 预设排版照尺寸 - SIX_INCH = [1205, 1795] - FIVE_INCH = [1051, 1500] - A4 = [2479, 3508] - THREE_R = [1051, 1500] - FOUR_R = [1205, 1795] - # 预设排版照尺寸字典 PRESET_LAYOUT_SIZE = { - LOCALES["print_switch"][language]["choices"][0]: SIX_INCH, - LOCALES["print_switch"][language]["choices"][1]: FIVE_INCH, - LOCALES["print_switch"][language]["choices"][2]: A4, - LOCALES["print_switch"][language]["choices"][3]: THREE_R, - LOCALES["print_switch"][language]["choices"][4]: FOUR_R, + choice: shape + for choice, shape in zip( + LOCALES["print_switch"][language]["choices"], + LOCALES["print_switch"]["shape"] + ) } choose_layout_size = PRESET_LAYOUT_SIZE[idphoto_json["print_switch"]] diff --git a/demo/ui.py b/demo/ui.py index 16da068..73895a3 100644 --- a/demo/ui.py +++ b/demo/ui.py @@ -351,7 +351,6 @@ def create_ui( value=LOCALES["print_switch"][DEFAULT_LANG]["choices"][0], interactive=True, ) - img_but = gr.Button(