Binalogue
Binalogue

Reputation: 55

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 image into cyberspace? This is easy to do in Android but we're struggling to find an easy solution for iPhone.

Upvotes: 0

Views: 845

Answers (3)

Jano
Jano

Reputation: 63697

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];
}

Upvotes: 1

Andrew
Andrew

Reputation: 2568

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

Upvotes: 0

Alex
Alex

Reputation: 393

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.

Upvotes: 0

Related Questions