2

When I save image to file it save with wrong orientation .

- (void)saveImage:(UIImage *)image:(NSString *)imageName
{
   NSData *imageData = UIImagePNGRepresentation(image);         
   NSFileManager *fileManager = [NSFileManager defaultManager];   
   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
       NSUserDomainMask, YES);
   NSString *documentsDirectory = [paths objectAtIndex:0];         
   NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:
      [NSString stringWithFormat:@"%@.png", imageName]];
   [fileManager createFileAtPath:fullPath contents:imageData attributes:nil];
}

Thanks.

Mundi
  • 79,884
  • 17
  • 117
  • 140
user1234096
  • 281
  • 1
  • 2
  • 6

1 Answers1

6

Try saving as a jpeg instead:

NSData *imageData = UIImageJPEGRepresentation(image,1.0);

If you need to save it as a PNG, check this discussion: UIImagePNGRepresentation ..... writeToFile is always landscape

Community
  • 1
  • 1
Dave
  • 356
  • 3
  • 4