将 UIImage 保存为 JPG 以将其传递给 Microsoft Face API

Save UIImage as JPG to pass it to Microsoft Face API

我正在尝试将所有联系人从 AddressBook 传递到 Cognitive Service Face Api 以让人们识别使用相机拍摄的照片上的人是否与保存在 AddressBook 中的人是同一个人。 据我所知,FaceApi 允许 JPG 照片,但 UIImage 不允许 如何将我拥有的照片作为 UIImage 保存到目录中,并在我已经从联系人中添加人名的字典中找到它的存储位置?

// convert a UIImage (img) into a JPEG stored in NSData
var data = img.AsJPEG(); 

// save NSData to file
data.Save(path);