Copy photo from album to album
I tried searching but it was not clear from what I found. I want to copy a photo from one album to another without creating a physical copy. In some of the examples it appears the image is opened, some reference a temp jpg on the file system or something. Anyhow I thought I could just get a reference/pointer to the photo from one album then add that reference to the other album. Anyone do this in straight python or does it require objc calls?
Assets in the photos module are essentially thin objects that point to actual image data. so, the images assets that you get from
photos.get_assets, or from an album's
assetscan be added to other albumns without creating copies.
#copy all albumns from first to second album src=photos.get_albumns() dest=photos.get_albumns() if dest.can_add_assets: dest.add_asset(src.assets) else: print('could not add') # add a single asset, must still be list dest.add_assets([photos.get_assets() ])
obviously, you would usually check the name of the albumn, etc. not all albumns can add assets, such as autogenerated albumns.
Thanks! That worked. Now just having a bit of an issue decoding the exif.
Here is what I am trying to do. I have 2 albums from a recent vacation with a lot of photos in each. One is from my phone (all live photos) and the other is from my dslr. They are each in date/time order and I want to merge both into one album sorted by date/time (I want to do this on the phone as to not lose the live photos). This logic is fairly easy as long as I can get photos from the two albums (which I can now - thanks!) and get the exif info from each to compare (the dates outside the exif may not reflect the actual time the picture was taken). The Image.info appears to have the exif data but looks to be Unicode or something. Have not had a chance to look into it further yet so if you have a quick solution to this that would be great.
photos.get_metadata might work for pictures taken by the phone. Iirc it doesn't give you exif data from dlsr images, but you can use the PIL methods to get that -- though you have to end up creating an Image.
I use piexif, see here