question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Edited photo path missing on Monterey

See original GitHub issue
  Sorry for the delay in providing answers to your questions. Here they go...

Could you try this:

Find photo P2071699 in your library. Verify that Photos shows the file as edited and try to export it using Photos (do not use “export unmodified original”, use “export 1 photo”). What I’m trying to figure out is if Photos itself knows where the edited image is or if its just showing you the preview image.

  • The “export 1 photo” worked correctly.

Another test would be to try to edit the edited photo in Photos. Does Photo show the edit screen or do you get an error about missing photo?

  • Hitting “Edit” it brings up the Photos Editing screen.

If Photos can find it and osxphotos can’t, I’ll need some additional data to figure out the problem.

  • I’ll upgrade from 0.54.4 to 0.55.1 and give it a go.
  • for now the osxphotos inspect of 0.55.1 continues not to show the Edite pic Path:
Path original: /Volumes/Macintosh HD/Users/Shared/Pictures/Pictures/iPhoto/2009-03-10-2126-29/P2071699.JPG
Path preview: /Users/Shared/Pictures/iPhoto Shared Library.photoslibrary/resources/derivatives/9/9D3E0182-87C9-4A58-ADCC-765C8512178B_1_202_a.jpeg

_Originally posted by @oPromessa in https://github.com/RhetTbull/osxphotos/discussions/856#discussioncomment-4395084_

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
RhetTbullcommented, Dec 20, 2022

Here’s an updated script to collect data on the adjustments. Please run this the same way and send the data. (This one won’t output any paths).

osxphotos run edited_paths2.py > debug2.txt 2>debug2_err.txt

""" Test edited paths for issue #871

    Upgrade at least osxphotos version 0.55.3 (https://github.com/RhetTbull/osxphotos/releases/tag/v0.55.3)

    Save as "edited_paths2.py" then run with command:

    osxphotos run edited_paths2.py > debug2.txt 2>debug2_err.txt 

    Then post debug.txt and debug_err.txt here or send to me directly at rturnbull+git@gmail.com

    If you need to specify the path to the library pass it as the first argument to the script:

    osxphotos run edited_paths2.py /path/to/library > debug2.txt 2>debug2_err.txt
"""

import csv
import os
import sys

import osxphotos


def verbose(msg):
    print(msg, file=sys.stderr)
    sys.stderr.flush()


def get_renders(photo):
    """Return list of render resources for given photo"""
    library = photo._db._library_path
    directory = photo._uuid[0]  # first char of uuid
    resource_dir = os.path.join(library, "resources", "renders", directory)
    resources = []
    if os.path.exists(resource_dir):
        resources.extend(
            filename for filename in os.listdir(resource_dir) if photo._uuid in filename
        )
    return resources


def main():
    verbose(f"osxphotos version: {osxphotos._version.__version__}")
    dbfile = sys.argv[1] if len(sys.argv) > 1 else None
    photosdb = osxphotos.PhotosDB(dbfile=dbfile, verbose=verbose)
    path_data = []
    for photo in photosdb.photos():
        if not photo.hasadjustments:
            continue

        candidate_path = photo._path_5()
        candidate_path_edited = photo._path_edited_5()
        renders = get_renders(photo)
        path_data.append(
            {
                "uuid": photo.uuid,
                "filename": photo.original_filename,
                "has_adjustments": photo.hasadjustments,
                "got_path": photo.path is not None,
                "got_path_edited": photo.path_edited is not None,
                "orientation": photo.orientation,
                "original_orientation": photo.original_orientation,
                "orientation_change": photo.orientation != photo.original_orientation,
                "adjustments": bool(photo.adjustments),
                "adjustment_data": bool(photo.adjustments.adjustments)
                if photo.adjustments
                else False,
            }
        )

    # print results as CSV
    fieldnames = path_data[0].keys()
    writer = csv.DictWriter(sys.stdout, fieldnames=fieldnames)
    writer.writeheader()
    for row in path_data:
        writer.writerow(row)


if __name__ == "__main__":
    osxphotos.debug.set_debug(True)
    main()
0reactions
RhetTbullcommented, Dec 22, 2022

Thanks – will take a look. Quick examination shows 884 images missing an edited path. Of these, 862 appear to be only an orientation change (photo was rotated) as the photo shows as edited but there’s no adjustment data in the plist file. Interestingly there appear to be 2143 images where there is an edited image path that also appear to be only an orientation change.

For the images where the edited path is missing and the only edit was an orientation change, osxphotos could conceivably do the rotation upon export (either through Quartz or through exiftool). For the others, I’m not sure what can be done if the files are truly not in the library. One idea might be to use PhotoKit to request the adjusted image in which case Photos would perform the adjustments in the plist and return the edited image. I’ve had reports of PhotoKit causing issues on Monterey (#625) so can’t be 100% sure this will work until we test it.

Can you try the following and let me know if it works?

osxphotos export /path/to/export --skip-original-if-edited --download-missing --use-photokit --uuid 1DA18E86-596B-4610-BE90-AAE89FAE4522 --verbose

If that works, then we may have a workable solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

After update to Monterey my pictures are … - Apple Community
You may have opened the wrong Photos Library. Quit Photos, if it is running. Hold down the options key ⌥ firmly while launching...
Read more >
How to Fix 'Photos Cannot Find the System Photo Library ...
Learn the best ways to fix 'Photos Cannot Find the System Photo Library' error that appears when trying to open Photos app on...
Read more >
NEW PHOTO FEATURE in mac Monterey - YouTube
There were a few new Apple Photo features when Apple released macOSX12 Monterey. One of which was the ability to import existing Apple...
Read more >
Here's How to Edit Photo Metadata on Mac (Easy) |
There are a few different ways to view and edit metadata on your Mac. Do it with Photos app, NOT Preview or Finder....
Read more >
Photos Disappeared or Lost on Mac after Update? 6 Solutions
However, unexpected errors may occur after Ventura, Monterey, Big Sur, Catalina or other version's update, the commonest one is that your photos in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found