-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add new export/process/reimport command (was Resized Library) #909
Comments
I was chatting with @oPromessa about something similar in #907 -- he's exporting old MPG files, converting to MOV and re-importing while preserving metadata. I think a general purpose "export - process - reimport with metadata" command would be helpful. In your case, the command could resize photos, in his case, convert files, etc. Not sure what a good name would be (open to ideas!) but maybe something like
which would do the following:
A few thoughts:
|
That's great, you got my ideas! For command name, I would suggest something like "shrinklibrary", or anyway something more verbose than expim. Unfortunately, i'm not into python world (only embedded C and C++, and some C# as hobby) |
Unfortunately that would only describe one possible use cases. I'm thinking of a more general tool that could be used any time you want to replace a photo in Photos while preserving the metadata. For example, another use case would be to strip the live video from live photos (see the link for an example script I'd previously done for osxphotos. Other ideas for the command name:
For shrinking photos another option would be to covert jpeg and other formats to HEIC. osxphotos already has code for converting HEIC to JPEG using MacOS native calls (with GPU acceleration) and this could easily be used to go the other way too. |
Stripping live video, converting RAW+JPEG to JPEG, converting RAW to JPEG, convert to HEIC... so many things I'd love to do with this. |
@rizwank yes! I'm thinking the interface would have some "pre-canned" actions as well as the option to run any arbitrary command or call another python function the user supplies (e.g. a plug-in). For example:
|
My vote on PS: or maybe |
Once nice feature might be ability to export (using osxphotos export) then re-import a low-res version but include in the metadata for the low-res version a link to the exported original. This would allow you to "archive" photos while maintaining the album structure and other metadata to trim your iCloud usage. This could be comined with an AppleScript that could be attached to a shortcut such that activating the shortcut while a photo is selected in Photos, finds the original exported version and reveals it in Finder or opens it in Preview. The original export path could be stored in the Photo's metadata (e.g the description) or in a separate key-value store to map re-imported photo to exported original. |
...or export to a new HiRes (offline) Library containing the original photos. |
Do you mean to a new Photos Library? That might be better (certainly easier to implement) as a two-step process:
Doing this requires using AppleScript and only one library can be scripted at a time (and switching libraries requires user interaction) so it will have to be multi-step no matter how implemented. |
Curious if this is still something you are considering. I'd personally love it; to be able to downres / remove combo RAW/JPG etc. |
@rizwank yes it's still on my list. The key to this is to be able to call the Apple APIs to request a change to the library. I have that prototyped but I'm working on figuring out how to use some undocumented private APIs so this can work with any library, not just the system library. I have that partially working. |
You are amazing. I don’t know if getting more users is important to you,
but I see this particular workflow ending up on the various Apple photos
blogs with a lot of interest.
…On Tue, Aug 29 2023 at 12:57 AM, Rhet Turnbull ***@***.***> wrote:
@rizwank <https://github.com/rizwank> yes it's still on my list. The key
to this is to be able to call the Apple APIs to request a change to the
library. I have that prototyped but I'm working on figuring out how to use
some undocumented private APIs so this can work with any library, not just
the system library. I have that partially working.
—
Reply to this email directly, view it on GitHub
<#909 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABWPZA2QA6VI7YF5V25JUTXXUO5NANCNFSM6AAAAAATZRWJZY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@rizwank thanks. I'm currently working on implementing a As an aside, I get about 10 hours/week to work on osxphotos (it's a hobby) and generally work on things in the following order:
|
Done with Some built in workflows wouldn't be hard but thinking about how to expose this transform capability to the user is more difficult for anything that's not an original photo or video with a single asset. Happy for any feedback on how people might want to actually use this capability. I think this will be very powerful once implemented but getting the details right is tricky. |
I've made progress on hacking the Photos private APIs. I can now fetch, export, and delete assets from any library. Deleting will pop up a dialog for confirmation but I can bulk delete with only a single dialog. Now on to editing! |
I can now add assets to the library without resorting to AppleScript but so far only for the system libary. Still working on reverse engineering the private APIs for adding. >>> from osxphotos.photokit import PhotoLibrary
>>> pl = PhotoLibrary()
>>> pl.add_photo("/private/tmp/test.jpeg")
'6526CC8B-6EA4-4CE8-8DDC-22168008F5DE/L0/001'
>>> And it should be straightforward to add live photos, raw+jpeg, videos this way so I can do a round-trip from Photos -> transform -> Photos for any asset type. |
Have import working for all libraries not just system libraries and can also now create libraries. |
I'm making good progress on the new code that will let me have near native access to the entire Photos library and this be able to implement this feature. I'm take a short pause to work on adding iPhoto support to osxphotos (see #40) because I have a personal need for this (reading an old iPhoto library on Ventura, which no longer supports iPhotos). Once done I'll get back to this. What are the "transform" features you would find most useful? I think |
Hi I saw your questions from some time ago:
Here are my 2cents: Live Photos
Videos
Strip unneeded stuff
Compression for unsorted images
I am thinking about image compression for the pictures which are not in an Album after some time, e.g. resize all images to 2048 pixels given some rules, e.g.: Not in an Album and older than 3 Months. This would leave me with high quality for the important ones, and acceptable quality for the rest. |
Thanks @ulilicht these are good use cases. This feature is on my roadmap but it's likely to be early next year before I can get this implemented). |
+1 for this! In the meantime I put together this script using osxphotos and ffmpeg specifically for finding the largest videos in my library, compressing them, and reimporting. Hopefully useful to others too. Do be careful though - not documented properly and limited testing (I've done about 100 videos so far). |
Thanks @danVnest that looks handy! I've been working on another companion library to osxphotos that would make this type work easier as it uses the native PhotoKit interface for interacting with the library and editing / replacing assets. It uses some private / undocumented features though (the public API is very limited) and this means it takes a fair bit more time for reverse engineering and testing. Once I get this done I should be able to implement this feature. |
That's great to hear @RhetTbull - good luck with the reverse engineering! |
Hello,
I would like to propose you a new feature.
Background: lot of people are using iCloud Photo Library - often shared with family -, and iCloud rates have also grown. Moreover, 95% of picture are food or useless stuffs.
Feature proposal: It would be nice to be able to export all library with high res photo, as we are already able to do, into our filesystem and replace each - or filtered group of - photo in the Library (i.e. iCloud) with a resized version (also containing the EXIF data, with geotagging), occuping less space.
Resize parameters and compression level can be chosen via command line.
Currently I've done this manually with Photos export feature, but it not convenient and error prone.
Thanks a lot,
Eugenio
The text was updated successfully, but these errors were encountered: