In principle, you can’t. But in practice, there is a way… Read on to find out.
iOS names the image IMG_<num> to avoid file name clashes. There is no way to change that from your app.
However, if the user later imports an image to iPhoto, then the metadata of the image will determine its title, description, and keywords.
If the user then exports the image to file, iPhoto can use the title for the name of the exported file. (Instructions for doing that are down below, after the code.)
Here is the code to set the metadata and save the image to the camera roll. The code below gets the image from the camera, but this isn’t necessary – the image can come from anywhere.
#import#import - (void) imagePickerController: (UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info { [self dismissViewControllerAnimated:YES completion:nil]; UIImage *image = info[UIImagePickerControllerOriginalImage]; NSMutableDictionary *metadata = info[UIImagePickerControllerMediaMetadata]; // set image name and keywords in IPTC metadata NSString *iptcKey = (NSString *)kCGImagePropertyIPTCDictionary; NSMutableDictionary *iptcMetadata = metadata[iptcKey]; iptcMetadata[(NSString *)kCGImagePropertyIPTCObjectName] = @"Image Title"; iptcMetadata[(NSString *)kCGImagePropertyIPTCKeywords] = @"some keywords"; metadata[iptcKey] = iptcMetadata; // set image description in TIFF metadata NSString *tiffKey = (NSString *)kCGImagePropertyTIFFDictionary; NSMutableDictionary *tiffMetadata = metadata[tiffKey]; tiffMetadata[(NSString *)kCGImagePropertyTIFFImageDescription] = @"Description for image"; // only visible in iPhoto when IPTCObjectName is set metadata[tiffKey] = tiffMetadata; // save image to camera roll ALAssetsLibrary library = [[ALAssetsLibrary alloc] init]; [library writeImageToSavedPhotosAlbum:image.CGImage metadata:metadata completionBlock:nil]; }
Now the user can import the images to iPhoto and get your programmed title, description, and keywords.
To export the images to files that have the same name as the image title, the user should choose File > Export and then change the File Name field to Use title.