Skip to content

Commit 614c718

Browse files
committed
update: enhance thumbnail generation logic and update .gitignore for dataset images
1 parent 10b47cf commit 614c718

3 files changed

Lines changed: 51 additions & 11 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ coverage
2727
*.sln
2828
*.sw?
2929
yarn.lock
30+
public/dataset/*.zip
31+
public/dataset/*/images/**/*.jpg
32+
public/dataset/*/images/**/*.png

scripts/generate_thumbnails.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""
3-
将 dataset/<outfit_id>/images 下所有图片按 540px 高度生成缩略图
4-
保持相同目录结构输出到 thumbnail/<outfit_id>/images。
3+
将 dataset/<outfit_id>/images 下所有图片按高度生成缩略图
4+
edited/look 为 540px,其余为 320px,保持相同目录结构输出到 thumbnail/<outfit_id>/images。
55
"""
66
from pathlib import Path
77
from PIL import Image
@@ -10,7 +10,8 @@
1010
PUBLIC = Path(__file__).resolve().parent.parent / "public"
1111
SRC_BASE = PUBLIC / "dataset"
1212
DST_BASE = PUBLIC / "thumbnail"
13-
TARGET_HEIGHT = 540
13+
HEIGHT_EDITED_LOOK = 540
14+
HEIGHT_OTHER = 160
1415

1516
# 支持的图片扩展名
1617
IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".webp", ".bmp", ".gif"}
@@ -26,16 +27,16 @@ def resize_to_height(img: Image.Image, height: int) -> Image.Image:
2627
return img.resize((new_w, height), Image.Resampling.LANCZOS)
2728

2829

29-
def process_image(src_path: Path, dst_path: Path) -> None:
30-
"""读取图片、缩放到 540 高度、保存到目标路径。"""
30+
def process_image(src_path: Path, dst_path: Path, target_height: int) -> None:
31+
"""读取图片、按指定高度缩放、保存到目标路径。"""
3132
dst_path.parent.mkdir(parents=True, exist_ok=True)
3233
with Image.open(src_path) as img:
3334
img.load()
3435
if img.mode in ("RGBA", "P"):
3536
img = img.convert("RGBA")
3637
else:
3738
img = img.convert("RGB")
38-
thumb = resize_to_height(img, TARGET_HEIGHT)
39+
thumb = resize_to_height(img, target_height)
3940
ext = dst_path.suffix.lower()
4041
if ext == ".png":
4142
thumb.save(dst_path, "PNG", optimize=True)
@@ -67,9 +68,13 @@ def main():
6768

6869
rel = src_path.relative_to(images_dir)
6970
dst_path = DST_BASE / outfit_dir.name / "images" / rel
71+
# edited 或 look 子目录下的图用 540 高度,其余用 320
72+
parts = rel.parts
73+
is_edited_or_look = len(parts) >= 1 and (parts[0].lower() == "edited" or parts[0].lower() == "look")
74+
target_height = HEIGHT_EDITED_LOOK if is_edited_or_look else HEIGHT_OTHER
7075

7176
try:
72-
process_image(src_path, dst_path)
77+
process_image(src_path, dst_path, target_height)
7378
total += 1
7479
print(f" {rel}")
7580
except Exception as e:

src/components/Main.vue

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ export default {
2626
"P01112310_b1",
2727
"P01127323_b1",
2828
"P00431909-P00958883-P00999111-P01006546-P01045238-P01086791-P01088627",
29+
"P00749634-P01023448-P01039809-P01056408-P01058346-P01075105-P01100395",
30+
"P00871983-P00908493-P00993397-P01063506-P01101088",
2931
"P00528279-P01056783-P01067920-P01072580-P01086754",
3032
"P00632317-P00947443-P00951042-P01004526-P01012440-P01115433",
3133
"P00697636-P00806175-P00956525-P01078473-P01081516",
3234
"P00741922-P00779847-P01005949-P01025038-P01052972-P01099646-P01114937",
33-
"P00749634-P01023448-P01039809-P01056408-P01058346-P01075105-P01100395",
3435
"P00762543-P00779803-P01054091-P01084304-P01092943-P01115291",
35-
"P00871983-P00908493-P00993397-P01063506-P01101088"
3636
],
3737
// 第 2 页(最多 16 个)
3838
imageOrderPage2: [
@@ -55,10 +55,42 @@ export default {
5555
],
5656
// 第 3 页(最多 16 个)
5757
imageOrderPage3: [
58+
"P00569647_b1",
59+
"P00632401_b1",
60+
"P00681208_d5",
61+
"P00714367_b1",
62+
"P00808132_b1",
63+
"P01010154_b1",
64+
"P01061467_b1",
65+
"P01067615_b1",
66+
"P00828534-P00883531-P00896044-P00941829-P00954111-P00995526-P01059740",
67+
"P00970270-P01010126-P01050852-P01057503-P01097208-P01118597",
68+
"P00942824-P00956577-P01014629-P01067220-P01085257-P01089574-P01122609",
69+
"P00859199-P00906290-P00939042-P01044154-P01057260-P01120547-P01131869",
70+
"P00832329-P00953880-P01060296-P01078496-P01080730-P01088827",
71+
"P01006785-P01011880-P01042654-P01068324-P01078459-P01082463-P01124415",
72+
"P00442628-P00963452-P01008681-P01047460-P01068439-P01069446-P01085200",
73+
"P00735962-P00935094-P00999304-P01001318-P01008910-P01138442",
5874
// 在这里填写第三页的 outfit id
5975
],
6076
// 第 4 页(最多 16 个)
6177
imageOrderPage4: [
78+
"P00589852-P01076940-P01080182-P01091935-P01095271",
79+
"P00987671-P01029444-P01058009-P01073791-P01086122-P01096102-P01127631",
80+
"P00772127-P00895682-P01018500-P01060747-P01088790-P01114910",
81+
"P00901579-P01006757-P01018496-P01060671-P01085931-P01091946",
82+
"P00589900-P00994134-P01068730-P01089929-P01114908",
83+
"P00727372-P00847443-P01087638-P01109213",
84+
"P01017047-P01080199-P01123021",
85+
"P00792759-P01020021-P01073867-P01099386",
86+
"P00772127-P00853771-P00959430-P01050333-P01085826",
87+
"P00824144-P01091937-P01101656-P01135755",
88+
"P00919111-P01003387-P01055299-P01057999-P01080700-P01093180",
89+
"P00589900-P00946107-P01071636-P01085827",
90+
"P00703295-P01057927-P01058002-P01085824-P01128035",
91+
"P01017672-P01080178-P01087823-P01097019",
92+
"P01055299-P01081922-P01085732-P01085932",
93+
"P01076025-P01085835-P01087648-P01099363-P01120639",
6294
// 在这里填写第四页的 outfit id
6395
],
6496
}
@@ -69,8 +101,8 @@ export default {
69101
return [
70102
this.imageOrderPage1,
71103
this.imageOrderPage2,
72-
// this.imageOrderPage3,
73-
// this.imageOrderPage4,
104+
this.imageOrderPage3,
105+
this.imageOrderPage4,
74106
].filter((page) => Array.isArray(page) && page.length > 0)
75107
},
76108
},

0 commit comments

Comments
 (0)