I've looked through tons of questions here in Stackoverflow and none of them solved my problem.
So, I'm using Apple's AVCam sample: http://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html
So, when I take a picture and save it in the image library it's fine, but when I show it in the screen by cropping it and when I send it to a server by using
NSData* pictureData = UIImageJPEGRepresentation(self.snappedPictureView.image, 0.9);
it sends it 90 degrees rotated!
Here is the code I crop it:
UIImage* cropped = [image imageByCroppingRect:CGRectMake(0, 0, (image.size.width * 300)/self.view.frame.size.width, (image.size.height * 300)/self.view.frame.size.height)];
imageByCroppingRect is:
- (UIImage *) imageByCroppingRect:(CGRect)area
{
UIImage *croppedImage;
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], area);
// or use the UIImage wherever you like
croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return croppedImage;
}