set type of an image captured using iPhone camera

camera, ios, iphone, objective-c, uiimagepickercontroller

Solution

This will help you to save image in png type

-(void)imagePickerController:(UIImagePickerController *)picker
  didFinishPickingImage : (UIImage *)image
             editingInfo:(NSDictionary *)editingInfo
{
NSError *error;

NSString  *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@.png",@"photoname"]];
[UIImagePNGRepresentation(image) writeToFile:pngPath atomically:NO];


NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

NSLog(@"Documents directory: %@", [fileManager contentsOfDirectoryAtPath:documentsDirectory error:&error]);

[self dismissModalViewControllerAnimated:YES];
}

Problem

If we capture a picture using iPhone camera, image will be saved in JPEG format by default. I would like to save the image captured in other formats like PNG. Is it possible? Is it possible to do this from code when we invoke iPhone camera from our application, can we set image type it has to be saved after capturing picture? I mean to open Camera and set the type before capturing picture?

Original source