title: Using CoreImage to filter an image results in image rotation
body: <p>Thanks for reading.</p>
  
  <p>I'm trying to use CoreImage in iOS 5 to alter the appearance of an image. The problem is that the existing image appears to lose its orientation information during the process and ends up rotated by 90 degrees.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>CIContext *context = [CIContext contextWithOptions:nil];
  CIImage *img = [CIImage imageWithCGImage:imageView.image.CGImage];
  CIFilter *adjustFilter = [CIFilter filterWithName:@"CIHighlightShadowAdjust"];
  
  [adjustFilter setDefaults];
  [adjustFilter setValue:img forKey:kCIInputImageKey];
  [adjustFilter setValue:[NSNumber numberWithFloat:0.3] forKey:@"inputShadowAmount"];
  CIImage *adjustedImage = [adjustFilter valueForKey:kCIOutputImageKey];
  UIImage *newPtImage = [UIImage imageWithCGImage:[context adjustedImage fromRect:adjustedImage.extent]];
  
  imageView.image = newPtImage;
  </code></pre>
  
  <p>The original image generally comes from one taken by the camera, but not always.</p>
  
  <p>Hope someone can help.</p>
  
  <p>Rob.</p>