Quantcast
Channel: User Bazinga - Stack Overflow
Viewing all articles
Browse latest Browse all 37

saving image with wrong orientation

$
0
0

I'm using the AGImagepickerContoller which could save multiple images from the camera roll, I am saving this way in the successBlock:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,    NSUserDomainMask ,YES );    NSString *documentsDir = [paths objectAtIndex:0];    NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"oneSlotImages%u.png", i]];    ALAssetRepresentation *rep = [[info objectAtIndex: i] defaultRepresentation];    UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];    //----resize the images    image = [self imageByScalingAndCroppingForSize:image toSize:CGSizeMake(256,256*image.size.height/image.size.width)];    NSData *imageData = UIImagePNGRepresentation(image);    [imageData writeToFile:savedImagePath atomically:YES];

My problem is when saving, and is used loaded in my preview. it looks like this:enter image description here

What I wanted is to have it like this in the preview:

enter image description here

I have read this iOS UIImagePickerController result image orientation after upload.

But I dont quite understand where I should put it in my code. Hope someone could guide in my problem. Thankyou.


Viewing all articles
Browse latest Browse all 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>