# 从文件夹中循环改变每一张图片 deffind_and_resize_pic_from_dir(dir_path, new_path): for root, dirs, files in os.walk(dir_path): for file_name in files: if file_name.lower().endswith('jpg') or file_name.lower().endswith('png'): file_path = os.path.join(root, file_name) new_file_path = new_path + file_name reset_pic_size(file_path=file_path, new_path=new_file_path)
if __name__ == '__main__': file_new_path = r'C:\Users\XX\Desktop\公众号素材\new_' find_and_resize_pic_from_dir(r'C:\Users\XX\Desktop\公众号素材', file_new_path)