2
votes

I am right now on the phase of recollecting information for a new iPhone app. For this app, i would like to use the camera and photo image editing options. Is Apple offering API (controller) where i can use this integrated IOs features into my app? i mean, in a process that starts first using the iPhone camera (IOS feature), later using the photo editing options (IOS feature), compress and tagg it (personal features), and finally save it inside my personal app folder/library (not inside general photo library)?

I have been reading the UIImagePickerController class feature, but i would like to double check with you, before moving forward

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

any idea for compressing the image or capturing it with less resolution?

thank you very much in advance

3

3 Answers

1
votes

Instead of capturing the image with less resolution you can resize image in the callBack of UIImagePickerController which is

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    UIImage *temp = (UIImage*)[info objectForKey:@"UIImagePickerControllerOriginalImage"];
    UIImage *uploadImage = [self resizeImageWithImage:temp];
}

For resizing function :

- (UIImage*)resizeImageWithImage:(UIImage*)image {
 CGSize newSize = CGSizeMake(newWidth, newHeight);
                UIGraphicsBeginImageContext( newSize );
                [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
                UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
                UIGraphicsEndImageContext();
}

You may need to use :

#import <QuartzCore/QuartzCore.h>

and the library.

Also for image editing check for CoreImage library which you can get information from here

http://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/CoreImaging/ci_intro/ci_intro.html

0
votes

For compressing this might help

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSData *imageData = UIImageJPEGRepresentation(image, 0.6);
    //0 means most compression
    //1 means least compression
}
0
votes

UIImagePickerController will let user either select existing photo or take a new one (it depends on how you set up the controller). The only editing that this approach allows is for user to crop the image. Other than that, you'll have to provide your own features.

As for compressing the image, you can save it as JPG while defining the compression ratio like so:

NSData *dataForPNGFile = UIImageJPEGRepresentation(yourImage, 0.9f);