Take the 2-minute tour ×

I am using UIImagePickerViewController to take photo from iPhone default camera in my App and storing it in Document directory. It is taking long time to complete the process and also it is displaying very slowly on tableview.Does resizing image help here?

    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
        imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:imgPicker animated:YES];

       UIImage *pickedImage = [info objectForKey:UIImagePickerControllerOriginalImage];    
    [self dismissModalViewControllerAnimated:YES];

    NSData *imageData = UIImagePNGRepresentation(pickedImage);

    NSString *path = [SAVEDIMAGE_DIR stringByAppendingPathComponent:@"image.png"];

    [imageData writeToFile:path atomically:YES];
share|improve this question

1 Answer 1

up vote 0 down vote accepted


I do the following in my app:

  • store the image in an image store in a background thread
  • create a thumbnail (also in background thread), store this thumbnail in a core data table; in an field of type ID

So I get a smooth UI, where the User can take about a picture every 2 seconds.

The smoothness of the table views are also no problem. Although I populate the TableViewCells ImageViews also from a background-thread (preparing the image in the background, assigning to the UIImageView in the mainthread, of course).

I hope, that helps you. Further questions are welcome.

Some code for your convenience:

As Imagestore I use these: https://github.com/snowdon/Homepwner/blob/master/Homepwner/ImageStore.m

    [self performSelectorInBackground:@selector(saveFoto:) withObject:info];
    // you should add some code for indicating the save process


// saves the photo in background-thread 
-(void)saveFoto:(NSDictionary*)info {
    // the following is some stuff that I do in my app - you will probably do some other things
    UIImage *image = [ImageHelper normalizeImageRotation: [info objectForKey:UIImagePickerControllerOriginalImage]];
    UIImage *thumb = [ImageHelper image:image fitInSize:CGSizeMake(imgWidth, imgWidth) trimmed:YES];
    NSString *myGUID = myGUIDCreator();
    [[ImageStore defaultImageStore] setImage:image forKey:myGUID];
    myCoreDataManagedObject.thumb = thumb;
    [self performSelectorOnMainThread:@selector(showYourResultsInTheUI:) withObject:thumb waitUntilDone:NO];  // every UI-Update has to be done in the mainthread!
share|improve this answer
code related to your answer will be helpful. –  user1831389 Jan 23 '13 at 13:50
if you need other snippets just ask –  Dominic Sander Jan 23 '13 at 14:18
thanx for help.When i send a captured image [through iphone] to server it is taking long time.but other images[imported images] are going fine. –  user1831389 Jan 24 '13 at 7:00
Yes, that´s true. Because of this I convert to a JPEG-Representation and reduce the quality a little bit: d = UIImageJPEGRepresentation(image, 0.8); You also can reduce the size of the image. Look after ImageHelper Source. –  Dominic Sander Jan 24 '13 at 8:31

Your Answer


