title: Updating an in-memory iOS UIImage with EXIF/geotag information
body: <p>I am trying to update a <code>UIImage</code> with geotag information.  I looked at <a href="https://stackoverflow.com/questions/3884060/saving-geotag-info-with-photo-on-ios4-1">Saving Geotag info with photo on iOS4.1</a>, which is where I found a reference to the <a href="https://github.com/gpambrozio/GusUtils/blob/master/GusUtils/NSMutableDictionary+ImageMetadata.m" rel="nofollow noreferrer">NSMutableDDictionary+ImageMetadata category</a>.  However, I don't want to save to the photo album, but have a <code>UIImage</code> to pass on.</p>
  
  <p>The following code seemed like it was making too many copies of the image and required all these frameworks linked: CoreImage, AssetsLibrary, CoreMedia, ImageIO.</p>
  
  <p>Is there something more efficient that <code>UIImage</code> -> <code>CIImage</code> -> <code>CGImage</code> -> <code>UIImage</code> that can take the properties NSDictionary needed for setting EXIF data?</p>
  
  <pre><code>- (UIImage *)updateImage:(UIImage *)image location:(CLLocation *)location dateOriginal:(NSDate *)dateOriginal
  {
      NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithDictionary:[image.CIImage properties]];
  
      // uses https://github.com/gpambrozio/GusUtils   
      [properties setLocation:location];
      [properties setDateOriginal:dateOriginal];
  
      CIImage *tempImage = [[CIImage alloc] initWithImage:image options:properties];
      CIContext *context = [CIContext contextWithOptions:nil];    
      UIImage *updatedImage = [UIImage imageWithCGImage:[context createCGImage:tempImage fromRect:tempImage.extent]];
  
      return updatedImage;
  }
  </code></pre>