0

After I get an image from iPhone gallery using imagePickerController I want to save that image in the app document directory, so I use this code:

-(void)saveImage:(UIImage*)image{

 NSString  *imagePath = [NSHomeDirectory()     stringByAppendingPathComponent:@"Documents/background.png"];

[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];

}

but the resulting file is in Landscape orientation also if the image was in Portrait orientation... If I try to see the image in a imageView on the xib the image result correct... (for example a 2448 × 3264 pic is showed right) but after I have saved that image the file that has been created is 3264 × 2448... Anyone know what can I do to avoid this change? Thanks a lot. Massy

Blue
  • 2,300
  • 3
  • 21
  • 32

1 Answers1

0

I finally understood why this was happening and find a solution... solution is to save Jpeg and not PNG as PNG lose the orientation when saving.

Blue
  • 2,300
  • 3
  • 21
  • 32