osxphotos: Edited photo path missing on Monterey

  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_

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

Got it. Yes the renders either show up or not! That explains it.

Thanks so much for the thorough feedback.

Will happily use --download-missing

I’ll eventually upgrade MacOS once I upgrade the hardware – hopefully next year 😄

BTW, Trimmed movies in Photos should be exported with the --skip-original-if-edited, correct?

Yes. I tested it and the trimmed video is exported in this case.

Bummer !

$ osxphotos export ./export --skip-original-if-edited --download-missing --use-photokit --uuid 1DA18E86-596B-4610-BE90-AAE89FAE4522 --verbose
osxphotos version 0.55.3
Using last opened Photos library: /Users/Shared/Pictures/iPhoto Shared Library.photoslibrary
Created export database /Users/Shared/Pictures/Export/edited_paths/export/.osxphotos_export.db
Processing database /Users/Shared/Pictures/iPhoto Shared Library.photoslibrary/database/photos.db
Processing database /Users/Shared/Pictures/iPhoto Shared Library.photoslibrary/database/Photos.sqlite
Processing database.
Database version: 6000, 7.
Processing persons in photos.
Processing detected faces in photos.
Processing albums.
Processing keywords.
Processing photo details.
Processing import sessions.
Processing additional photo details.
Processing face details.
Processing photo labels.
Processing EXIF details.
Processing computed aesthetic scores.
Processing comments and likes for shared photos.
Processing moments.
Done processing details from Photos library.
Exporting 1 photo to /Users/Shared/Pictures/Export/edited_paths/export...
Exporting P5130204.JPG (P5130204.JPG) (1/1)
Skipping original version of P5130204.JPG
Exporting edited version of P5130204.JPG (P5130204.JPG)
Skipping missing edited photo P5130204.JPG (1DA18E86-596B-4610-BE90-AAE89FAE4522)
Exporting 1 photos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processed: 1 photo, exported: 0, missing: 1, error: 0
Elapsed time: 0:00:00

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()