我不确定我是否在减少图像尺寸方面做错了,或者是通过保存云来实现的。
我用相机或相机胶卷拍摄图像并将其保存到解析云中。当我检索此图像并显示它时,它将向左旋转90度。
我检查了云上的图像并保存了旋转。但是当我用相机拍照并且在缩小尺寸之前在UIImageView
显示它时,它不会旋转。
这是我的代码:
NSData *imageData = UIImagePNGRepresentation(userImage.image);
if (imageData.length > 10485760) {
UIImage *compressedPNGImage = [UIImage imageWithData:imageData];
NSLog(@"Image is over sized");
UIGraphicsBeginImageContext(CGSizeMake(480,320));
//CGContextRef context = UIGraphicsGetCurrentContext();
[compressedPNGImage drawInRect: CGRectMake(0, 0, 480, 320)];
UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageData = UIImagePNGRepresentation(smallImage);
PFFile *file = [PFFile fileWithName:@"pic.png" data:imageData];
PFQuery *query = [PFUser query];
[query getObjectInBackgroundWithId:[[PFUser currentUser] objectId] block:^(PFObject *user, NSError *error) {
user[@"image"] = file;
[user saveInBackground];
}];
saveImageBtn.hidden = true;
}