RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
2k stars 94 forks source link

Remove RAW images from Apple Photos #1660

Open vodium-vastro opened 4 weeks ago

vodium-vastro commented 4 weeks ago

Hi,

I'm not sure if this is already possible, but couldn't see anything obvious in the documentation.

I have approx 2000 RAW files with 1400 RAW+JPEG in my Apple Photos Library. I would like to delete all the RAW files if they have a matching JPEG to try and reduce the file sizes.

Is there a way to do this with osxphoto without having to manually export and reimport the images?

Many thanks

RhetTbull commented 4 weeks ago

There is currently no way to automatically do this in OSXPhotos. There is an open issue (#909) to add a new command for this type of thing and I've made some progress on this but it will be a while before I have time to complete it. In the meantime, you can do this following to simplify the export and re-import while preserving all metadata, albums, etc. (with exception of persons/faces which cannot be preserved upon import). This requires running only 2 OSXPhotos commands.

Create a new folder to export to. For demonstration purposes we'll use /Volumes/Photos:

Export just the JPEG version of all RAW+JPEG pairs:

osxphotos export /Volumes/Photos--skip-raw --has-raw --add-exported-to-album "Exported RAW+JPEG Photos"

This exports just the JPEG (--skip-raw) of all RAW+JPEG pairs (--has-raw) to the folder and adds those photos to the album "Exported RAW+JPEG Photos" in Photos (which will be created if necessary). This is so you can easily delete the photos after the next step.

Then run this command to import the JPEG images while restoring metadata from the export database created by Photos.

osxphotos import /Volumes/Photos/* --exportdb /Volumes/Photos

This will restore titles, captions, keywords, location, albums, and favorite status from the export database for the new JPEG copies. Unfortunately it won't restore date/time/timezone changes. (For example, you changed the creation time in the Photos info dialog). I've opened #1661 to fix this.

Finally, once you've confirmed the import worked as expected, you can delete the RAW+JPEG files (Which should now be in the "Exported RAW+JPEG Photos" album). To delete the photo instead of just removing it from the album when in album view, you use Cmd+Delete which moves the photo to the Recently Deleted folder.

vodium-vastro commented 4 weeks ago

Hi @RhetTbull ,

Thanks for the guidance. I followed your steps but in this order:

However when I look in the newly imported album the files are all still showing JPG+RAW.

If I pick one image in Apple Photos and Export Unmodified original both a jpg and nef are saved. Do I need to purge from recently deleted first?

Or do I need to do the other like you said and delete after the import?

RhetTbull commented 4 weeks ago

Did you export with the osxphotos export command I suggested? If so, did the NEF file get exported? If it did, then there's a bug in osxphotos as the --skip-raw option should have caused the RAW image to be skipped. Please provide the exact command you used for export and import and verify whether or not there were RAW images in the export folder.

If the NEF file got exported in step 1 then the import command would automatically re-associate the RAW+JPEG which is why the intent was to skip the export of the raw images in step 1.

vodium-vastro commented 4 weeks ago

Hi,

  1. Yes, I used your command to export with a few minor tweaks: osxphotos export Desktop/JPG\ of\ RAW --skip-raw --has-raw --add-exported-to-album "Exported RAW+JPEG Photos" --use-photokit --skip-original-if-edited --download-missing

  2. No, the raw files were not exported to the folder from command in 1, only jpg's were in the folder (and a few HIEC's) CleanShot 2024-08-21 at 13 02 00@2x

  3. Import command was osxphotos import Desktop/JPG\ of\ RAW/* --exportdb Desktop/JPG\ of\ RAW --album "IMPORTED OLD RAWs"

CleanShot 2024-08-21 at 12 59 42@2x

Many thanks.

vodium-vastro commented 4 weeks ago

FYI osxphotos, version 0.68.5

RhetTbull commented 4 weeks ago

That's very odd. What version of macOS?

If you have have a pair you don't mind sharing, can you export using "export original" from Photos and send to me at osxphotos.py@gmail.com ? I'm wondering if there's some embedded metadata tag that is causing the imported JPEG to be associated with the RAW file already in Photos. (This is true of Live Photos).

vodium-vastro commented 4 weeks ago

On 14.6.1. Will send something over shortly via email.

Many thanks

vodium-vastro commented 4 weeks ago

Email sent

AndiH commented 2 weeks ago

Thanks for the write-up! I also have a library which is overflowing with raw pictures. So, any functionality to directly get rid of raw versions in a library (without the export-import business) would be greatly appreciated!