Reload macOS Photos location metadata - swift

I have a macOS Photos extension where I update the metadata for the photo. The metadata (location information) is saved correctly, but the Photos application does not recognise the changes since it seems like it is storing its own location information about the photos separately from the photo itself. If I manually export the photo from Photos and re-import it, the location is properly shown in Photos.
Is there a way (in Swift) to trigger a reload of the metadata or to re-import the photo into Photos?

Related

Get photo that is saved to photo library in swift

So I have a image which I get from my server. I want to save that image locally. I have already considered using Userdefaults or Core Data for this instead, but I want the user to be able to see and view the photos from their photos app. So I have a saved photo which is saved using UIImageWriteToSavedPhotosAlbum. How do I later retrieve that same image in my app? This includes even after the app is closed and relaunched.
Are you using the PHPhotoLibrary framework? If so, you can use PHFetchOptions to fetch the photos that were saved by your application. Enter parameters such as album name to retrieve the photos you have saved.
If you have the url of the image being stored using UIImageWriteToSavedPhotosAlbum then use that url to retrieve that image using FileManager API.
Get image from documents directory swift

Retrieve and change data in iPhone photo library

Now, I've managed to get list of album and photos using this module..https://github.com/quickstonesw/Appcelerator-Urban-Image-Library.
So, in my app, I can create new album, delete album, move photo from album to another album and delete photo. When i create album and delete album, it works nicely in app but after creating new album, when check in default photo library, the album is not there. Right now, I'm working on move photo and delete photo.
My question is:
1) if it is possible, how can I add the album that I've created in app to the default photo library?
2) if question 1 is possible, how do I delete it?
3) How do I move photo from album to album and reflect it back to default photo library?
4) delete the photo from photo library if i deleted it in my app
Is all question above possible to be done or not? Is there another module that I can use to achieve it? I'm using titanium latest SDK 3.0.2 and am building for iPhone only.

Unique identifier of photos in iPhone photo library

I am going to develop an app that will basically work as a catalogue for the photos taken from an iPhone app (saved in photo library). I am thinking about creating an SQLite database (catalogue) and mapping it to photos in the photo library (correct me if this approach is wrong).
What would be the best way to map the photos and the SQLite database?
I want to avoid the case that user changes name of the file and link between file and DB doesn't work anymore.
You can store photos in Base63 string into your SQLite database.
And for the Unique identifier of photos you can user imagename_curentUnixTimestamp.jpg.
you can use current date and time to give a name of photo and store it document directory.
also save name of photo into database.when required load photo from document directory as per it's name stored in db.

phonegap get photo file's original imageURI

phonegap's camera API has this iphone quirk noted:
When destinationType.FILE_URI is used, photos are saved in the application's temporary directory.
details here
and when I load the photo from album, I get imageURI like this
file://localhost/var/folders/sV/sVG0cyUrFvKs6+6I16IO+U+++TI/-Tmp-/photo_007.jpg
and every time I get a different URI for the same photo. Is it possible to get the URI of the original photo file instead of the temporary copy? I need to have the image URI and display multiple photos on the same screen.
Thanks for your help.
Actually it is not possible on iOS as the photos are stored in an area that is not accessible via URL. We need to copy the image to the application specific temp directory so it will be readable by your app.

How to count total photos on iphone

I am trying to count total photos on the iphone and get the total filesize. What is the best way?
At least in 2.x SDKs, you can't access actual photo files programmatically from code. However, you can access thumbnails of photos which you can use to get a count of photos.
Original photo themselves are in a special database file (/private/var/mobile/Media/Photos/Photo Database) and thumbnail pictures are in a directory (/private/var/mobile/Media/Photos/Thumbs).
Photos can be accessed only through interactive UIImagePickerController. Reverse engineering Photo Database file format is the only way I can see that would give you an access to original photo files programmatically.
I haven't checked the situation for 3.0 SDK, it might give you some API to access photos programmatically.