I successfully saved the image Photo Libraryusing the Photo Framework APIs after the user selected this image from the library using UIImagePickerController.
As I capture the image inside my application, I have to take care of the metadata. I could save the location and createDate for the newly captured image and save it to the library.
But the problem is that I want to attach a ton of other properties, I want to say that I want to attach properties EXIFand TIFF.
There EXIFare many properties like
kCGImagePropertyExifDateTimeOriginal
kCGImagePropertyExifMaxApertureValue
kCGImagePropertyExifSpatialFrequencyResponse
kCGImagePropertyExifLensModel
How can I get these values from the current device and attach it to the image and save it to Photo Library?
Here is the complete code that I use to save the image in Photo Libraryafter removing it from UIImagePickerController. I would like to add metadata line bindings somewhere in this function before storing them in Photo Library.
class func savingThis(image : UIImage, completion : (asset : PHAsset?) -> ())
{
var localIdentifier : String?
let imageManager = PHPhotoLibrary.sharedPhotoLibrary()
imageManager.performChanges({ () -> Void in
let request = PHAssetChangeRequest.creationRequestForAssetFromImage(image)
request.location = LocationManager.sharedInstance.locationManager.location
request.creationDate = NSDate()
if let properAsset = request.placeholderForCreatedAsset {
localIdentifier = properAsset.localIdentifier
}
else {
completion(asset: nil)
}
}, completionHandler: { (success, error) -> Void in
if let properLocalIdentifier = localIdentifier {
let result = PHAsset.fetchAssetsWithLocalIdentifiers([properLocalIdentifier], options: nil)
if result.count > 0 {
completion(asset: result[0] as? PHAsset)
}
else {
completion(asset: nil)
}
}
else {
completion(asset: nil)
}
})
}
This is a stupid question? I do not need to use the Photos Framework, if there is another way to attach the metadata, in any way, I just want to attach it. I dont know. Let me know your suggestions?
user6375148
source
share