开发者

resizing a photo in iPhone before sending to a server

Making an app where we want to send a photo to a server along with some form data. The image is huge and it takes forever to upload and we really don't need the pixel information on the website. Is there any way to resize an image (from camera or your gallery) so that we're only sending a much smaller开发者_如何学Python image into cyberspace? This is easy to do in Android but we're struggling to find an easy solution for iPhone.


See Resize a UIImage the right way for resizing code and discussion. To pick the image you can do

// select image
UIImagePickerController *picker = [UIImagePickerController new];
picker.delegate = self;
picker.allowsEditing = YES;
[yourViewController presentModalViewController:picker];

// delegate method
- (void) imagePickerController:(UIImagePickerController *)picker 
 didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
}


The most of you question issues is covered by WWDC 2010 session N104. There is a scroll views, but methods, which described there can be using in you task.


In UIImage:

 + (UIImage *)imageWithCGImage:(CGImageRef)imageRef scale:(CGFloat)scale orientation:(UIImageOrientation)orientation

Just scratching out an idea...

UIImage smallerImage = [[ UIImage imageWithCGImage: biggerImage.CGImage scale: 0.1 orientation:  orient
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜