假设你有两张图,地址分别是jpg_path和out_jpg_path,如果你想要把jpg_path的元信息写入out_jpg_path用下面的语句
with pyexiv2.Image(jpg_path) as jpg_xmp: # 使用with就会自动关闭 jpg_xmp = jpg_xmp.read_xmp() jpg = cv.imread(jpg_path) newjpg = DistortionCorrection(jpg,jpg_xmp) cv.imwrite(out_jpg_path,newjpg) with pyexiv2.Image(out_jpg_path) as newjpg_xmp: newjpg_xmp.modify_xmp(jpg_xmp)