Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit 479fd07

Browse files
fix: 修复批量水印中的字体的路径问题 (#183)
* style: 一些样式修改 * style: 默认否 * fix: 修复路径问题
1 parent 393a20e commit 479fd07

File tree

5 files changed

+16
-23
lines changed

5 files changed

+16
-23
lines changed

src/Tools/【实验性工具】/图片处理/批量水印.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@
1616
#----
1717

1818
while True:
19-
text_ttf = input("请输入自定义字体文件完整路径(默认Arial.ttf):")
20-
21-
# 如果用户没有输入任何内容或者输入了"默认",则将变量值设为 "Arial.ttf"
22-
if not text_ttf or text_ttf == "默认" or text_ttf == "Arial.ttf":
23-
text_ttf = "Arial.ttf"
19+
text_ttf = input("请输入自定义字体文件完整路径: ")
20+
# 自动处理引号
21+
text_ttf = text_ttf.strip('\"')
22+
if os.path.exists(text_ttf):
2423
break
24+
# 检查文件路径是否存在
2525
else:
26-
# 自动处理引号
27-
text_ttf = text_ttf.strip('\"')
28-
if os.path.exists(text_ttf):
29-
break
30-
# 检查文件路径是否存在
31-
else:
32-
print("[WARN] 自定义字体文件不存在")
26+
print("[WARN] 自定义字体文件不存在")
3327

3428
# 计算水印文字的宽度
3529
text_width = len(watermark_text) * 25
@@ -59,7 +53,7 @@ def add_watermark(image_path, watermark_text, text_where, move_text):
5953

6054
# 创建水印图片
6155
watermark = Image.new("RGBA", image.size, (0, 0, 0, 0))
62-
font = ImageFont.truetype("D:\\...ttf", 40) # 使用默认字体和大小
56+
font = ImageFont.truetype(text_ttf, 40) # 使用默认字体和大小
6357
draw = ImageDraw.Draw(watermark)
6458

6559
# 计算水印文本的位置
@@ -83,10 +77,10 @@ def add_watermark(image_path, watermark_text, text_where, move_text):
8377
watermarked_image.save(save_path)
8478
# only test on 4032*2268
8579
if image.width != 4032 or image.height != 2268:
86-
print("[WARN] 本工具仅在4032*2268的图片上测试过,其他图片效果可能不理想。\n本张图片大小:",image.width,"*",image.height)
80+
print("[WARN] 本工具仅在 4032*2268 的图片上测试过,其他图片效果可能不理想。\n本张图片大小:",image.width,"*",image.height)
8781
print(f"[INFO] 水印已成功添加到 {save_path}\n")
8882
else: # 其他
89-
print (f"[WARN] 仅支持16:9的图片。错误文件: {image_path}\n")
83+
print (f"[WARN] 仅支持 16:9 的图片。错误文件: {image_path}\n")
9084

9185
except Exception as e:
9286
print(f"[ERROR] 添加水印时出现错误: {e}")

src/Tools/哈希值校验/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def main():
4141
if __name__ == "__main__":
4242
main()
4343

44-
input("按Enter键继续...")
44+
input("按Enter键继续...")

src/Tools/字母大小写互换/字母大小写互换.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main () {
1111
if (a[i] >= 'a'&&a[i] <= 'z') {
1212
a[i] -= 32;
1313
} else if (a[i] >= 'A'&&a[i] <= 'Z') {
14-
a[i] +=32;
14+
a[i] += 32;
1515
}
1616
}
1717
//---

src/Tools/缓存清理/缓存清理.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
for file in files:
3939
file_paths.append(os.path.join(root, file))
4040
break
41-
elif temp.lower() in ["n", "no", "否", "不"]:
42-
break
4341
elif temp.lower() in ["a", "always", "总是"]:
4442
print("设置中...")
4543
# 修改ini文件配置
@@ -49,7 +47,8 @@
4947
print("设置完成!")
5048
break
5149
else:
52-
print("请按说明回答!")
50+
# elif temp.lower() in ["n", "no", "否", "不"]:
51+
break
5352
if ac_ctr:
5453
for root, dirs, files in os.walk(ctr):
5554
for file in files:
@@ -80,7 +79,7 @@
8079
finally:
8180
pbar.update(1)
8281
print("缓存文件删除完成!")
83-
# 对于TEMP↑ 对于Windows.old ↓
82+
# 对于TEMP ↑ 对于Windows.old ↓
8483

8584
windows_old_path = 'C:\\windows.old'
8685

src/temporarily/config-save.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def check_folder(destination_folder):
3131
if len(os.listdir(destination_folder)) != 0:
3232
print(f"\r{Fore.RED}✕ 错误的目标文件夹: {Fore.BLUE}{destination_folder}\n{Fore.YELLOW} 原因:目标文件夹不为空。")
3333
return False
34-
34+
3535
print(f"{Fore.GREEN}\r{Fore.RESET} 已选择保存到的文件夹: {Fore.BLUE}{destination_folder}")# 刷新,避免被顶掉
3636
return True # 一切正常
3737

@@ -54,7 +54,7 @@ def copy_config_files(destination_folder):
5454
continue # 忽略源文件夹中的config.ini
5555
destination_path = os.path.join(destination_folder, relative_path)
5656
destination_dir = os.path.dirname(destination_path)
57-
57+
5858
# 创建目标文件夹中的子文件夹(如果需要)
5959
if not os.path.exists(destination_dir):
6060
os.makedirs(destination_dir)

0 commit comments

Comments
 (0)