Невозможно сохранить exif-данные, полученные из AvcaptureSession при передаче в UIImage - PullRequest
0 голосов
/ 06 мая 2019

Я получаю изображение, снятое с устройства в методе didFinishProcessingPhoto delegate, который дает изображение с exif data, но когда я передаю его на UIImage, оно теряет exif metadata

public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {

        let imageData = photo.fileDataRepresentation()
        // Function to get meta data

        let exifDataValue = getEXIFFromImage(imageData)
        print("Exif data \(exifDataValue)")
        // Getting exif data here


        let uiImage = UIImage.init(data: imageData!)
        let pngData = uiImage?.pngData()
        let exifDataValue2 = getEXIFFromImage(pngData)
        print("Exif data \(exifDataValue2)")

       // Not getting exif data here

}

func getEXIFFromImage(image:NSData) -> NSDictionary {

        let imageSourceRef = CGImageSourceCreateWithData(image, nil);

        let currentProperties = 
        CGImageSourceCopyPropertiesAtIndex(imageSourceRef!, 0, nil)
        print(" currentProperties \(currentProperties)")
        let mutableDict = NSMutableDictionary(dictionary: currentProperties!)

        return mutableDict

    } 
...