Question

i had done a camera function and trying to make a photo edit after capture image. but the problem is when i run the photo edit, the process is very slow, because the picture is not yet exist on the album. so i try to save the image to photo album after i capture the image. but now how i can point back the same image from the photo album without let the user do any selection on photo album? means after capture and save the image, how i can use coding auto call back the image to direct move to editing? i using UIImageWriteToSavedPhotosAlbum for saving the image.

Was it helpful?

Solution

Instead of saving that captured image in Photo album before edit why not you save it in Document folder of application. To edit the photo take it from document folder and then save that edited photo into photo album. If you want to get that photo from photo album then you have to show image picker controller for same. So i suggest save it in Document folder. Also getting photo from Document folder is faster.

 - (IBAction)saveImage 
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
        UIImage *image = imageView.image; // imageView is my image from camera
        NSData *imageData = UIImagePNGRepresentation(image);
        [imageData writeToFile:savedImagePath atomically:NO];   
    }

    - (IBAction)getImage {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
        UIImage *img = [UIImage imageWithContentsOfFile:getImagePath];
    }

To remove the image

NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:cImagePath error:nil];

cImagePath will be the path of image

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top