Save image captured by Camera into Documents Directory in ios
12,654
Try
UIImage *image = [UIImage imageNamed:@"Image.jpg"];
NSString *stringPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0]stringByAppendingPathComponent:@"New Folder"];
// New Folder is your folder name
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:stringPath])
[[NSFileManager defaultManager] createDirectoryAtPath:stringPath withIntermediateDirectories:NO attributes:nil error:&error];
NSString *fileName = [stringPath stringByAppendingFormat:@"/image.jpg"];
NSData *data = UIImageJPEGRepresentation(image, 1.0);
[data writeToFile:fileName atomically:YES];
Author by
Parimala
Updated on July 02, 2022Comments
-
Parimala almost 2 years
Hi I am new to iPhone Environment. I am using the Xcode 4.5. I am developing the Camera Application now. I want to save the image is taking from the Camera to a Separate folder in Documents Directory and also in a Custom album in Photo Library .. I am saving the images to Custom album in Photo Library but I don't know how to save it to Documents Directory... Can anyone tell me how to do this..?
-
Parimala about 11 yearsThanks for your response..I tried this code its working but Where Do I have to seen that image to check the image size..?
-
Girish about 11 yearsTry following path : Finder -> Go -> Go to Folder -> /Users/GirishS/Library/Application Support/iPhone Simulator. Replace GirishS with your system name.
-
Parimala about 11 yearsIn Application Support it is not showing the iPhone Simulator..!
-
Girish about 11 years- Execute the following command on terminal to unhide the hidden folders. chflags nohidden ~/library/
-
Parimala about 11 yearsiPhone Simulator is not showing after executing the above command..
-
Girish about 11 yearsStill iPhone simulator is showing or not....
-
Girish about 11 yearsIt works for me, don't know why not worked for you? try following link stackoverflow.com/questions/8738019/…