iOS - Is it possible to rename image file name before saving it into iPhone device gallery from app?
There is a way to kinda do that, by setting the image IPTC metadata field "Object Name". If you later import the image to iPhoto, then this name will be used as its title.
See details (and code) at http://ootips.org/yonat/how-to-set-the-image-name-when-saving-to-the-camera-roll/ .
user2786
Updated on July 09, 2022Comments
-
user2786 almost 2 years
Hey I'm new to iPhone and I have been trying to make an gallery kind of app. Basically, what I want to do is that i need to save all the captured images into a specific folder like a new album "My_App Images" related to our app name in iPhone device gallery, it's working for me, but I am having trouble to change the image file name, i don't know that Is it possible to specify a file name? Using iPhoto, currently i am getting image file name as "IMG_0094.jpg", can we change it with any other file name like "Anyfilename.png" format programmatically?
here is my code for saving images to the specific album :
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { [self.library saveImage:image toAlbum:@"My_App Images" withCompletionBlock:^(NSError *error) { if (error!=nil) { NSLog(@"Image saving error: %@", [error description]); } }]; [picker dismissViewControllerAnimated:NO completion:nil]; }
Any source or link for reference is appreciated. Thanks for the help!
-
user2786 about 10 years@FahimThanks, but my requirement is to save all captured images into device gallery with a specific file name as i have mentioned in my question. So for saveImage: toAlbum: withCompletionBlock method, i need to change save image filename before calling this method..
-
Fahim Parkar about 10 yearsthen define the new file name and use it... do you have problem in defining new file name?
-
user2786 about 10 years@AnindyaThanks alot..even still i am searching for the same. My requirement is to save all captured images into device gallery with a specific file name..
-
Anindya Sengupta about 10 yearsChanging name seems to be not possible at all. You have to depend on
AssetLibrary
. However you can change the metadata if that somehow suits your need. Metadata includes information like description, camera, location etc. Here is how to do it: link For that you will have to use– writeImageDataToSavedPhotosAlbum: metadata: completionBlock:
-
user2786 about 10 years@AnindyaBut using writeImageDataToSavedPhotosAlbum: metadata: completionBlock:, we cant save photo in a specific folder Album on device..it will save in Camera Roll only...
-
Anindya Sengupta about 10 yearsVisit this: touch-code-magazine.com/… It has got a demo (essentially a Category) which shows how to save to to custom photo library using the
writeImageDataToSavedPhotosAlbum: metadata: completionBlock:
method -
Jirson Tavera over 7 yearsYou don’t have permission to save the file “ customImageFilename.jpg” in the folder “100APPLE" :/