REST API access for changing metadata of photos #6868
Replies: 1 comment 1 reply
-
There is a REST API for this. Unfortunately API endpoints are not yet surfaced in a way that the end user can quickly use but it is definitely possible. You can use the updateFilePublicMagicMetadata function in the web app's source as a reference (there'll be similar code in the mobile app if you're more comfortable reading dart). This function eventually calls the PUT /files/public-magic-metadata endpoint. The export const updateFileCaption = (file: EnteFile, caption: string) =>
updateFilePublicMagicMetadata(file, { caption }); In your case, you wish to modify the GPS coordinates, which get saved as the So you should be able to, e.g. open the dev tools in your browser, edit the caption for a file, and copy the network request that gets send when you edit the caption. However, this is where you'll run into a roadblock. The public magic metadata is end to end encrypted! So it is not going to be just about copying the REST request and modifying the JSON directly, you'll need to also
These steps are not too hard, but I also understand that if you don't have context of the code they might seem very hard. The simplest suggestion I can think of is run a modified web client where you can maybe temporarily repurpose some existing function to do your bidding. For example, you can start your web app locally
Change the definition of export const updateFilePublicMagicMetadata = async (
file: EnteFile,
updates: FilePublicMagicMetadataData, // ignore this
) =>
updateFilesPublicMagicMetadata([file], {lat: latForFileID(file.id), lng: lngForFileID(file.id) }); where latForFileID etc are functions where you obtain the new coordinate (if it is only a few files you can also just hardcode them and change your code as you go through the files). Then you can trigger this function by doing something that modifies the file's public magic metadata (e.g. changing the file name or caption or date). You can also trigger it in bulk by, e.g. selecting the photos you want to update, use the "Fix time" option on the selection actions bar and update their time (which'll eventually call your modified function). We do hope to in the future provide an SDK where custom functionality can be done by the user in case the app doesn't support the exact behaviour they wish for yet. Right now however, something like the above might solve your predicament. Maybe there is an even easier way, this is the solution that just came to my mind casually. While it's obvious, I'll restate - this is just a hacky workaround, please undertake on your own risk etc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to add metadata to my photos via a script - namely GPS coordinates. Is there a way to access the REST API for this?
(My use case: when editing photos with snapseed they lose their location data. I'd like to read the location data from the original jpegs and write it back to the edited files' metadata on ente. I already have the part where I read the coordinates from the unedited files - just sending them to ente seems impossible...)
Beta Was this translation helpful? Give feedback.
All reactions