title: How to preserve original photo metadata when editing PHAssets?
body: <p>I am editing photos via PhotoKit but I discovered this does not preserve the original photo's metadata. This occurs even with the SamplePhotosApp provided by Apple when they apply Sepia or Chrome filters. My question is, how do you ensure all the original photo metadata is preserved?</p>
  
  <p>I've discovered how you can obtain the original image's metadata, and I was able to save that metadata to the final <code>CIImage</code> I create, but it still is stripped out when the edit is committed. There must be an issue in the way I convert the <code>CIImage</code> to a <code>CGImage</code> to a <code>UIImage</code> to <code>NSData</code>, or how I'm writing it to disk.</p>
  
  <pre><code>asset.requestContentEditingInputWithOptions(options) { (input: PHContentEditingInput!, _) -&gt; Void in
      //Get full image
      let url = input.fullSizeImageURL
      let orientation = self.input.fullSizeImageOrientation
      var inputImage = CIImage(contentsOfURL: url)
      inputImage = inputImage.imageByApplyingOrientation(orientation)
  
      //do some processing on original photo here and create a CGImage...
  
      //save the original photo's metadata to a new CIImage:
      let originalMetadata = inputImage.properties()
      let newImage = CIImage(CGImage: editedCGImage, options: [kCIImageProperties: originalMetadata])
  
      println(newImage.properties()) //correctly prints all metadata!
  
      //commit changes to disk - somewhere after this line the metadata is lost
      let eaglContext = EAGLContext(API: .OpenGLES2)
      let ciContext = CIContext(EAGLContext: eaglContext)
      let outputImageRef = ciContext.createCGImage(newImage, fromRect: newImage.extent())
      let uiImage = UIImage(CGImage: outputImageRef, scale: 1.0, orientation: UIImageOrientation.Up)
      let jpegNSData = UIImageJPEGRepresentation(uiImage, 0.75)
  
      let contentEditingOutput = PHContentEditingOutput(contentEditingInput: input)
      let success = jpegData.writeToURL(contentEditingOutput.renderedContentURL, options: NSDataWritingOptions.AtomicWrite, error: _)
  
      PHPhotoLibrary.sharedPhotoLibrary().performChanges({ () -&gt; Void in
          let request = PHAssetChangeRequest(forAsset: asset)
          request.contentEditingOutput = contentEditingOutput
      }, completionHandler: { (success: Bool, error: NSError!) -&gt; Void in
          if success == false { println('failed to commit image edit: \(error)') }
      })
  })
  </code></pre>
  
  <p>Original - note the GPS tab:<br>
  <img src="https://i.stack.imgur.com/Ga7Fh.png" alt="Original photo&#39;s metadata"></p>
  
  <p>After editing the photo:<br>
  <img src="https://i.stack.imgur.com/v1imL.png" alt="enter image description here"></p>