Update:
With iPhone OS 3.0+, the whole UIImagePickerController API has changed. This question and answer should be considered 2.2. legacy code.
When using the UIImagePickerController and you allow editing of the image. The iPhone allows the user to resize and pan the image. However, the max size of an edited image is capped at 320×320.
As an example, I took an iPhone screenshot and placed it in the photo library, which is a 480×320 png. When I use a UIImagePickerController to select that image, even if I do NOT scale or pan the image, it is cropped to 320×320 before it is returned from the UIImagePickerController. However, if I turn editing off, the image is returned the proper 480×320 size.
My theory: Very subtly, the iPhone displays 2 nonstandard translucent tool bars that overlay over the image. These toolbars leave an innocuous 320×320 ‘window’ over the photo. It appears to me that this window effectively clips the underlying photo.
Note: The callback also returns an editing dictionary with the original image and the clipping rect, but of course the rect is also max 320×320.
Any ideas on how to allow images larger than 320×320 to be scaled and panned?
Some code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { self.myImageView.userInteractionEnabled=YES; CGRect imageFrame = myImageView.frame; CGPoint imageCenter = myImageView.center; imageFrame.size = img.size; myImageView.frame = imageFrame; self.myImageView.image = img; myImageView.center = imageCenter; [self dismissModalViewControllerAnimated:YES]; [self performSelector:@selector(hideToolBars) withObject:nil afterDelay:2.0]; }
As craig said, this is an issue in the dev forums and apples regular discussion board. I did, however, find a way around it. I’m using a bit of code from:
Apple Dev Forums
This includes most of what you need, and takes care of all the camera orientation issues. I’ve added the following which will take in the editing info and use it to get the original cropping rect with this addition:
I updated the call back method from the dev forums post to the following: