Recently I’ve been discussing formatting address data then from Apple Photos. This was for use in my ongoing Wallpaper shortcut. I described it as…
… It does need PixelMator Pro to run…
The aim of it is to select a random ‘favourite’ photo from my Apple Photos, adjust the size and crop where needed to fit the desktop, tint the picture by a defined amount (30% currently), overlay a ‘widget’ at the screen bottom, which shows; Address, ‘camera’ used, and the datestamp of when it was taken, finally a bit of debug data saying when it was set.
I know I’ve got a lot of variable cleaning up to do, there are probably better ways of doing some of things I’ve done. Planned:
Settings moved into a dictionary
Work around to get rid of duplicate Postcode data
Work around to get rid of duplicate Street data
Save out various 'debug data - ful address, Map URL, ’ etc into a defined Apple Note
Look to see if the overlays can be done without using Pixelmator
Option to add a ‘mini’ Map overlay image bottom right (may be too small to be useful)
@peavine I’ve now updated the shortcut (not re-uploaded as still testing) to parse the split lines to handle situations where the post code is in the street (still testing) and line one is the post code (that works).
dbrewood. I tested your new shortcut and encountered one issue (which you may be aware of). If the photo has no location data, the If Street has any value action and the If Latitude has any value action are both found to be true, which results in the final wallpaper as shown below. I don’t know of a fix, but I’ll spend some additional time on this later today.
More as a matter of personal preference, the code that resizes a portrait image appears to work as expected, but it often returns a result that might not be desired. A temporary workaround that avoided this with my test photos was to add a condition to the Find Photos action requiring that the width of any found photo be greater than 3500 pixels. Anyways, I thought a user option to skip portrait photos might be a nice enhancement.
These are, of course, minor issues and the shortcut continues to work great.
dbrewood. I found a possible solution for the location issue. The Get Location action returns a location object. and with my test photo the location is the Atlantic Ocean. Nothing can be done with this. However, if the location data is missing, the Street property returns an empty string. So, testing the length of the street property can be done as shown below. With this change, the shortcut correctly showed No Location on the wallpaper.
In the new version I’ve re-looked at the locational data (needs rewriting as soon as I can) as what it really needs to check whether the full address we use for the split is null or not. At the moment though isolating the best source for that data is proving to be an issue (not got tome to check - family issues). Once identified then the investigation ‘loops’ used can be simplified and reworked
The split code has been adjusted and now uses [PC] & [Str in TC] indicators after the ‘street portion’ of the widget text - these indicate if - line 4 contains line 1 omit line 1 (postcode in line 1), and line 2 contains line 1 - omit line 1 (Town/city includes street). Easier to see when in operation.
[PC] code reworked and moved into the ‘otherwise’ portion of the loop.
A LOT of address tweaks made as I found some of the address changes you mentioned caused issues with addresses not showing at all on a number of my photos where addresses are present.
Added the width limit you suggested when selecting an image.
Once the ‘location loop’ situations are resolved I now need to work on speeding things up, initial selection of the image is way too slow!
dbrewood. You had earlier mentioned the possibility of using a dictionary for some of the shortcut settings, and I was interested in how this might be implemented. Just as an interesting project for me to work on, and possibly for your use when the location/address issues are resolved, I tested the following, which seemed to work OK. Getting the tests in the if statements to work correctly was a bit of a chore, though.
The latest (test) version is attached. Changes are:
Location code simplified and reformatted, it now works using the ‘Full Address’ which is the data used on the split lines. I’ve been testing all my scenarios here and it looks good (so far)
Multi-location code removed
Debug code removed as no longer really needed
Removed Pixelmator Pro overlay code and replaced with Apple Shortcut function
Hopefully it should work better and faster for you.
I did some testing and if a US address is a street address, the lines are in the format of:
3800 Main St
Prescott AZ 86305
United States
If the address is not a street address, the lines are in the format of:
Ridge Top Trail
Prescott AZ 86305
United States
If the photo has no location information, the shortcut returns 0 lines for address.
Given the simplicity of US addresses, I rewrote your shortcut on a proof-of-concept basis for US addresses. This is of no help to you, but I mention this only because the use of line count to test for location/no-location seems to work well. The only other change I made was to eliminate Favorites as a filter, and I did that to facilitate testing.
The following screenshot shows the section of the shortcut that I edited.
BTW, in limited testing, I’ve been impressed with the ability of the shortcut to determine my location when in the forests near my house. I may repurpose your shortcut for my own use to work on a single file selected in a Finder window.