iPhone UIImagePickerController file name - iphone

after getting a selected image in didFinishPickingImage:, is there a way to get the filename or name of that image? Is there any string that uniquely identifies that image or that is saved with the image at the moment image was added to the photo album?

You can check the metadata, but from my tests the title does not seem to be there or anywhere else.

Related

How to get path of images with IOS 16 image picker SwiftUI

Good day,
How do I get the path of images from the ios 16 Photos Picker(PhotosUI Library) as I am trying to store the path in a json file to retrieve later to display
I have a form with a image picker and I want to store the path in json file and then later retrieve the path from the json file to show the image on another view.
There are no images and no paths. The photo library is a database.
You can get the photo asset's identifier if you have permissions, and then you can use that elsewhere to fetch the same photo from the database.

Getting image name of iphone photo library

I'm doing a project to take images from iphone photo library or in other way from camera roll. I have done that without any problem. But i need to retrieve the name from the photo library. Is there a way to do that? Any help is appreciated
Thanks
Have a look at ALAssetsLibrary which is available in iOS 4.0 and later.
Also, these links may help
How to get a photo's original filename in iOS?
iPhone: How do I get the file path of an image saved with UIImageWriteToSavedPhotosAlbum()?
If you need the full path, just use this:
ALAsset* asset; // previously assigned
NSDictionary* pathInfo = [asset valueForProperty:ALAssetPropertyURLs];
This will leave the full URL of the image on your device as the Value member of the pathInfo object.

Save a UIImage to a different name

I am writing an application which lets the user pick one photograph from a selection. Then I want to save that photograph to their photo roll to a specific name. i.e I always want the photo in the roll to be named the same thing and overwrite previous selections.
UIImage* image = [UIImage imageNamed:[ImageNames objectAtIndex:self.miImage]];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
I can't find anyway to make a copy of the image and assign a new name to it, or specify a target name for UIImageWriteToSavedPhotosAlbum().
Is there any way to do this?
thanks in advance,
Jay
You cannot specify a filename when using UIImageWriteToSavedPhotosAlbum because it saves the image to the Camera Roll (or the Photos Library, if the device does not have a camera). This allows the system to assign it a name based on a format, like "DSC0001.jpg" or similar, and avoid name collisions.
Because of this, overwriting an image is also not possible, since the Photo Library / Camera Roll are controlled by the user - a user that would not appreciate a photo being overwritten by your application.
...writing the image to the user’s Camera Roll or Saved Photos album.
UIImageWriteToSavedPhotosAlbum Reference

iPhone application cannot load images from an album

I have developed a small iPhone application in which a user can choose images from an image picker and that image will appear in a View. When the user first selects an image I have saved the image name to a database and I save that image to a resource folder with that name. When the main view appears I search for images from the resource folder and display that image in the main view.
When I run this application in the iPhone Simulator it successfully runs, but when I actually tried it for testing purposes on my iPhone I am not able to display images in the main view. Anyone have an idea what's wrong with that?
Hi shivang,
I think you are saving the image to NSDocumentDirectory on a first click and trying to reload that.
while retriving the files from the NSDocumentDirectory you better
first check it for the file type like jpg,png,mp3 then give the
exact name to retrive that.
NSDocumentDirectory creates unique memory for every app and its
limited,check for the size of the images u r saving.
better try this code
for (NSString* fileName in [fileManager contentsOfDirectoryAtPath:myfilepath error:nil])
{
if ( [fileName rangeOfString:#".jpg"].location != NSNotFound )
{
// Here fileName is used as a temporary variable to retrive image name
// myfilepath is the path where u stored the images
}
}

Save photo to iphone camera roll with a custom name

I am trying to save a photo taken from my app to camera roll, this can be done by using UIImageWriteToSavedPhotosAlbum, however, I noticed there isn't any way to set the photo name by using this approach, am I right?
I also tried to save a image file with a name by using UIImageJPEGRepresentation, however, I can only save it to my app's document folder but not camera roll.
Is there any way to save photo to camera roll with a custom name?
Thanks advance for your kindly help.
John
no, no way to save with a custom name to the camera roll.
There is a way to kinda do that, by setting the image metadata:
if you set the IPTC metadata field "Object Name", this will be shown as the image title in iPhoto.
See details (and code) at http://ootips.org/yonat/how-to-set-the-image-name-when-saving-to-the-camera-roll/ .