omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    photos - get original (heic) file and its name

    Pythonista
    photos module
    2
    3
    932
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MichalOprendek
      MichalOprendek last edited by

      Is there a way how to obtain original (heic) file, i. e. the same binary content as downloaded to computer via e. g. Microsoft Photos or uploaded when using Dropbox / Nextcloud? Is there a way how to obtain the original ordinal filename e. g. IMG_0810.heic?

      I am trying to use Pythonista to create a reconciliation script that identifies pictures not backed up to my home server. I am able to compare files either by content or by date, time & filename.

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @MichalOprendek last edited by cvp

        @MichalOprendek tested, it works for heic photos, but try

        import photos
        from objc_util import *
        assets = photos.get_assets()
        asset = photos.pick_asset(assets)
        filename = str(ObjCInstance(asset).valueForKey_('filename'))
        data = asset.get_image_data().getvalue() # bytes
        with open(filename, mode='wb') as fil:
        	fil.write(data)
        
        1 Reply Last reply Reply Quote 0
        • MichalOprendek
          MichalOprendek last edited by

          Thanks! It worked.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors