2 Commits

Author SHA1 Message Date
67016c4e9a Merge branch 'dev' 2025-12-31 15:00:04 +08:00
69c3634731 refactor: 图片迁移脚本
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s
2025-12-31 14:58:48 +08:00

View File

@@ -672,13 +672,18 @@ def create_example_config(config_file: str):
def read_image_paths(image_list_file: str) -> List[str]:
"""从文件读取图片路径列表"""
paths = []
not_images = []
try:
with open(image_list_file, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if line and not line.startswith("#"):
if not line.endswith((".png", ".jpeg", ".jpg", ".gif", ".webp")):
not_images.append(line)
else:
paths.append(line)
print(f"从文件读取 {len(paths)} 个图片路径")
print(f"从文件读取 {len(paths)} 个图片路径数据行")
print(f"从文件中读取到 {len(not_images)} 个非图片路径数据行")
except Exception as e:
print(f"读取图片路径文件失败 {image_list_file}: {e}")
return paths
@@ -889,9 +894,14 @@ def main():
print("请使用 --input 指定文件或直接在命令行提供路径")
sys.exit(1)
origin_paths = image_paths
# 去重
image_paths = list(set(image_paths))
repeats = len(origin_paths) - len(image_paths)
if repeats > 0:
print(f"从文件中读取到 {repeats} 个重复图片路径数据行")
# 创建并运行迁移器
migrator = ImageMigrator(
source_config=source_config,