import os
from PIL import Image
import numpy as np
def resize(imgPath,savePath):
files = os.listdir(imgPath)
files.sort()
print('Input Pic Add:',imgPath)
print('Starting...')
for file in files:
fileType = os.path.splitext(file)
if fileType[1] == '.jpg':
new_png = Image.open(imgPath+'/'+file)
matrix = 255-np.asarray(new_png)
new_png = Image.fromarray(matrix)
new_png.save(savePath+'/'+file)
print('Progressing:',file)
print('Done!')
if __name__ == '__main__':
# Before Pic Add
dataPath = '/Users/sukanu/Desktop/2021-12-05_104027'
# After Pic Add
savePath = '/Users/sukanu/Desktop/ok'
resize(dataPath,savePath)
本文作者 : Sukanu Xian
本文采用 CC BY-NC-SA 4.0 许可协议。转载和引用时请注意遵守协议、注明出处!
本文链接 : https://blog.ssf.moe/455.html