新增一张文字图片

将输入模式改好
This commit is contained in:
Luthics 2023-01-09 00:22:59 +08:00
parent ad3274826b
commit 007d16227c
2 changed files with 12 additions and 12 deletions

BIN
imgs/text.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

24
main.py
View File

@ -5,18 +5,18 @@ from tqdm import tqdm
# 输入数据
# img = input("请输入图片路径:")
# new_width = int(input("请输入新宽度(px)"))
# new_height = int(input("请输入新高度(px)"))
# print("模式 0 双线性插值")
# print("模式 1 最邻近插值")
# print("模式 2 高斯模糊缩放")
# mode = int(input("请输入模式:"))
img = input("请输入图片路径:")
new_width = int(input("请输入新宽度(px)"))
new_height = int(input("请输入新高度(px)"))
print("模式 0 双线性插值")
print("模式 1 最邻近插值")
print("模式 2 高斯模糊缩放")
mode = int(input("请输入模式:"))
img = 'imgs/xjtu.bmp'
new_width = 256
new_height = 256
mode = 1
# img = 'imgs/text.bmp'
# new_width = 2560 * 3
# new_height = 2560
# mode = 0
if (mode not in [0, 1, 2]):
mode = 0
@ -347,7 +347,7 @@ for i in tqdm(range(len(newpixels)), "将像素点格式化中"):
# 写入新的文件
newimgBytes = bytes(newimgArray)
with open(img[:-4] + "_" + str(mode) +"_new" + img[-4:], 'wb') as f:
with open(img[:-4] + "_" + str(mode) + "_new" + img[-4:], 'wb') as f:
f.write(newimgBytes)
for _ in tqdm(range(len(newimgBytes)), "写出图片中"):
pass