Forum Archive

photos - get original (heic) file and its name

MichalOprendek

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

@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)
MichalOprendek

Thanks! It worked.