开发者

How to copy a photo from Camera Roll to app's Documents folder as a JPG/PNG?

How can I copy/move a photo from Camera Roll to an app's own Documents folder? UIImagePickerController returns a UIImage * by:

(UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage]

How can I save the UIImag开发者_JAVA百科e * as a file (best with all the EXIF information embedded)?


Try using following code

NSData *data = UIImagePNGRepresentation(image);
NSArray *UsrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *DocsDir = [UsrDocPath objectAtIndex:0];
    NSString *path = [DocsDir stringByAppendingPathComponent:@"contents.png"];
    //Remove if necessary
    BOOL success = [FileManager fileExistsAtPath:path];
    if(success){
        [FileManager removeItemAtPath:path error:&error];
    }
    [data writeToFile:path atomically:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜