'Photos' and promised files(?)

I freely admit my knowledge here is sparse.

If I want to browse and open a photo on a Mac,
and Photos app is handling the images
then I have reports that selecting a picture in the file browser doesn’t actually get me a picture.

I have a nagging feeling that when Photos is involved, what I ‘get’ is a kind of promise, or some URL, rather than a binary file holding pixels.

Am I right, and if so, how do I get hold of the ‘thing’ that Photos wants to tell me about, other than making customers save the Photos image as a ‘real’ file to a ‘real’ location?

What you’re getting is probably a “Bookmark” which you can read about here:

Have you tried the photo picker classes in macOS to let the user pick a picture?

See PHPickerViewControllerMBS

Not yet. I had thought it was only iOS.

Having typed in the example, however, autocomplete shows that my plugins (v23) do include PHPickerViewControllerMBS (there are two constructors)
But compiling gives an error that there is no such class.

I added MacOS support in v23.2.

OK. The help page suggested v22. I guess the autocomplete was telling me about the iOS only classes.
Thanks for the info.

Apple considers Photos within Photos to be inaccessible by 3rd parties (security, you know), even a Photos plugin doesn’t get access to the original images.

The file promises are not to the file, they’re to where Photos will create a JPEG copy of the photo, last time I tried, there was NO way to use a RAW image with anything else, unless you manually go spelunking through the file structure.

Apple go as far as to obfuscate the file name, so you’ll need to allow Photos to create and save a JPEG copy, read the meta data and then assemble the file name and path of where the photo will be, delete the copy created by Apple’s Photos and then directly access the RAW file.

For many years you could use the Apple’s Media Selector, but that hasn’t worked in recent OS versions.

While PHPickerViewController should solve the problem, it’s only available on macOS since Ventura, so for older version you may find yourself SOL.

It’s all gone absolutely insanely stupid.

1 Like

And it’s the same thing for podcasts, music on iOS, and probably others…

1 Like

I wrote you a blog post on how to use the picker class:

Picking picture on macOS

1 Like

Thats great. Thank you Christian. Clearly what Photos ‘offers’ is a mishmash of things.
That blog will be helpful in presenting an OS-familiar interface

My own investigations have shown that (if the source image is a simple PNG or JPG, at least), then when Photos is running, Photos shows up as a folder in Finder.
Selecting an image from there, I am presented with a long nativepath which includes

“com.apple.Photos.NSItemProvider”
so right now, if the path contains that string, I am delaying trying to use the picture by a short time, then checking for nil and exists etc.
(Im not yet sure how that will cope with a file that is HEIC or a ‘liveimage’ at this point )