feat: dynamic layout print (#229)

* update

* Update README.md
This commit is contained in:
Ze-Yi LIN
2025-01-21 19:58:27 +08:00
committed by GitHub
parent 9c67303784
commit 51264b0f03
4 changed files with 10 additions and 13 deletions
+4
View File
@@ -378,6 +378,10 @@ docker run -d -p 7860:7860 \
- 修改`demo/assets/title.md`
## 5. 如何添加/修改「打印排版」中的尺寸?
- 修改`demo/locales.py`中的`print_switch`字典,添加/修改新的尺寸名称和尺寸参数,然后重新运行`python app.py`
<br>
# 📧 联系我们
+1
View File
@@ -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"],
+5 -12
View File
@@ -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"]]
-1
View File
@@ -351,7 +351,6 @@ def create_ui(
value=LOCALES["print_switch"][DEFAULT_LANG]["choices"][0],
interactive=True,
)
img_but = gr.Button(