RhetTbull / locationator

A simple macOS menubar app that provides access to the macOS Location Services reverse geocoding API via a local web server as well as a command line tool.
MIT License
17 stars 0 forks source link

Add Finder Service to add XMP data #8

Closed RhetTbull closed 8 months ago

RhetTbull commented 8 months ago

Add the locationator write-xmp feature to a Finder Service.

gspannu commented 8 months ago

Hi, How is this coming along... any updates?

Thanks...

RhetTbull commented 8 months ago

Haven't started. Will get done when it gets done 😀

RhetTbull commented 8 months ago

Taking a slight detour from this...I figured out how to read the EXIF/IPTC/XMP metadata using native calls so exiftool not needed which will help with the service. Now working on being able to write this data natively. I think I can make this work without exiftool at all.

gspannu commented 8 months ago

Taking a slight detour from this...I figured out how to read the EXIF/IPTC/XMP metadata using native calls so exiftool not needed which will help with the service. Now working on being able to write this data natively. I think I can make this work without exiftool at all.

Wow.... that is quite something...

Although on a separate note... EXIFtool is used extensively by a lot of people, its read/write methods have been tested extensively, and support for new camera and metadata is updated very regularly.

Do you run the risk of having to update your code more frequently, as and when file formats change or some new versions of XMPdata get released?

Would it be better to support both (native and Exiftool) - since you have already written the EXIFtool wrapper?

---------- Update ---------- I see another advantage that people would be find it easier to modify the EXIF calls in your code rather than native calls. e.g. I am looking at modifying some of your EXIF calls to 'hardcode' some additional entries and create my own personal build. Not done this yet, but will look at this at sometime.

I would much appreciate, if you could support both methods and make it user selectable in the menu item.

RhetTbull commented 8 months ago

Do you run the risk of having to update your code more frequently,

I'm using Apple's macOS APIs for reading/writing metadata so that's Apple's problem, not mine.

Would it be better to support both (native and Exiftool)

Nope, this is a side project for fun and adding more features means adding more maintenance and I only need a working solution, not a configurable solution.

I see another advantage that people would be find it easier to modify the EXIF calls in your code

They could do that with the native solution too -- it's python code just like the exiftool interface would be (If I do use exiftool, I'll use my own ExifTool python wrapper).

I haven't tried it yet but I suspect that calling exiftool from the app is going to run into problems just like the CLI installer did (#10), namely the subprocess won't be able to access files because it will run in a protected environment. Services work by passing a pasteboard with an NSURL to the serving app and the app has permission to the files in the urls because it was user initiated, thus getting around the system integrity permissions. If I pass the file to an external process, I'm betting it won't work...but I'll test it.

I really want to do this natively for another project so there's an added benefit to implementing it this way.

I would much appreciate, if you could support both methods and make it user selectable in the menu item.

I don't plan to do that at this time but the code is open source so you are welcome to add this. Again, I need to test this first to see which solution works best but the goal of this project is to do one specific thing, not be a general purpose exiftool wrapper.

gspannu commented 8 months ago

Understood... all valid reasoning.

RhetTbull commented 8 months ago

Initial Service is working. This one performs the reverse geocoding and copies result to clipboard. Will work on the "write to XMP" service next.

Screenshot 2023-10-24 at 10 21 50 PM
gspannu commented 8 months ago

Initial Service is working. This one performs the reverse geocoding and copies result to clipboard. Will work on the "write to XMP" service next.

Screenshot 2023-10-24 at 10 21 50 PM

Small suggestion... Could you make the sub-menu item text (Get reverse geocoding with Locationator) shorter.... e.g. maybe something short like Reverse Geocode ?

... or maybe follow another method, where there is a main sub-menu called 'Locationator' and then sub-sub-menus under it. Locationator>

RhetTbull commented 8 months ago

Can't do nested menus in Services

RhetTbull commented 8 months ago

This is what I've got for Services at the moment.

Screenshot 2023-10-27 at 6 41 10 AM

As I suspected, exiftool cannot be called by the app due to sandboxing. I will figure out how to do this using the native APIs.

Screenshot 2023-10-27 at 6 40 18 AM

It might be possible to package exiftool inside the App bundle but exiftool for macOS isn't a standalone binary and requires several libraries to also be installed. Not worth my time to figure that out for "it might work" solution which will likely still run into sandbox issues.

RhetTbull commented 8 months ago

The "write XMP" Service appears to be working. It does not work with RAW though. exiftool can write the metadata fields to the RAW file but the CoreGraphics / ImageIO routines don't appear to be working for writing to RAW. They read the metadata from the RAW files just fine.

RhetTbull commented 8 months ago

Services implemented in v0.1.0. The write XMP service doesn't work with RAW files but that's a problem for someone else to solve.