[Python] osxphoto save photodb image to local file using python

Discussão em 'Python' iniciado por Stack, Maio 25, 2025.

  1. Stack

    Stack Membro Participativo

    Using osxphotos (python) to organize photos. The code below gets list of all photo's and their information. The problem is that export is not working. From either photodb.export() or photo.export(). Any help is appreciated.

    Here is the code:

    import osxphotos

    phDB = osxphotos.PhotosDB()

    phList = [ph for ph in phDB.photos() if ph.filename == '10E7B798-493D-4F82-A5ED-F65C0D66CD12.jpeg']
    print("Photos found:", len(phList))

    ph = phList[0]
    bn = ph.original_filename
    fn = ph.filename
    print("Photo:", bn, fn)

    phDB.export(
    path="../testExport",
    filename=fn
    )


    but I get the following error:

    Photos found: 1
    Photo: IMG_0697.jpg 10E7B798-493D-4F82-A5ED-F65C0D66CD12.jpeg
    ---------------------------------------------------------------------------
    AttributeError Traceback (most recent call last)
    Cell In[18], line 13
    10 fn = ph.filename
    11 print("Photo:", bn, fn)
    ---> 13 phDB.export(
    14 path="../testExport",
    15 filename=fn
    16 )

    AttributeError: 'PhotosDB' object has no attribute 'export'


    Also, for photo.export() it gives error: TypeError: PhotoInfo.export() got an unexpected keyword argument 'path'

    Continue reading...

Compartilhe esta Página