本地图片的image加密解密-
Python 3.10
pyt3int22 -根据1zip下图片批量生成加密的-物体识别.py
import ioimport os
import base64
import json
# 指定图片文件夹
image_dir = "./1zip/"
base64code_dir = "./base64code/"
base64_to_dir = "./base64_to_dir/"
import csvdef image_to_base64(image_path):"""将图片转为 Base64流:param image_path: 图片路径:return:"""# with open(image_path, "rb") as file:# base64_data = base64.b64encode(file.read()).decode('ascii') # base64编码# return base64_datawith open(os.path.join(image_dir, image_path), "rb") as f:image_bytes = f.read()base64_encoded_image = base64.b64encode(image_bytes)# print(base64_encoded_image)return base64_encoded_imagen = len(os.listdir(image_dir))
for image in os.listdir(image_dir):print("rows", len(os.listdir(image_dir)))base64code = image_to_base64(image)# print(base64cod