-
|
First of all, thank you for the awesome tool. I didn't use it soo much, just bought it yesterday, but the custom keyboard is really nice! I could create SHA1 for photos Here is the script for calc sha1 for images Edit: I just found out, that import photos
import hashlib
import base64
import csv
import os
from objc_util import ObjCInstance, ObjCClass, nsurl
PHAssetResource = ObjCClass('PHAssetResource')
PHAssetResourceManager = ObjCClass('PHAssetResourceManager')
assets = photos.get_assets(media_type='image')
output_rows = []
assets.reverse()
for asset in assets:
try:
# Zugriff auf das native Asset
objc_asset = ObjCInstance(asset)
resources = PHAssetResource.assetResourcesForAsset_(objc_asset)
# Hole Dateinamen vom ersten Resource-Objekt
resource = resources.firstObject()
filename = str(resource.originalFilename())
print('filename', filename)
# Bilddaten holen
data = asset.get_image_data().getvalue()
# SHA1 berechnen
sha1 = hashlib.sha1(data).digest()
b64 = base64.b64encode(sha1).decode('utf-8')
output_rows.append((b64, filename))
break
except Exception as e:
print(f"❌ Fehler bei Asset: {e}")
# Speichern als CSV
output_path = os.path.expanduser('~/Documents/photo_hashes.csv')
with open(output_path, 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['base64_sha1', 'filename'])
writer.writerows(output_rows)
print(f"✅ Fertig! Datei gespeichert unter: {output_path}") |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Since you already have the asset resources as ObjC objects, you're almost there! Here's how you could get the video file for a live photo: # ...
resources = PHAssetResource.assetResourcesForAsset_(objc_asset)
for r in resources:
# PHAssetResourceTypePairedVideo = 9
if r.type() == 9 and r.isLocallyAvailable():
file_url = r.privateFileURL()
video_path = str(file_url.path())
print(f'Live photo video file: {video_path}')
# ... |
Beta Was this translation helpful? Give feedback.
Since you already have the asset resources as ObjC objects, you're almost there!
Here's how you could get the video file for a live photo: