Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support arbitrary sidecar files #210

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

qlyoung
Copy link
Contributor

@qlyoung qlyoung commented Aug 31, 2023

Currently support exists for handling .xmp sidecar files. This change expands that support to any arbitrary sidecar file. It also expands the set of sidecars which are handled by default. The new default set, and the reason this set was chosen, is:

  • .xmp - general metadata format for all image types; written by Lightroom, Digikam, Darktable, etc
  • .json - generated by google takeout when exporting from g photos
  • .yml/.yaml - used by Photoprism

Users can override this default set by passing the new --sidecars option. For example, to handle .xyz, users should pass --sidecars="xmp,json,yml,xyz"; and to disable sidecar handling altogether, pass --sidecars=''

As with my other patch, I'm submitting this without tests so we can reach consensus about the feature.

Example

Before the change, .json sidecars are placed in unknown rather than being moved with their images:

[2023-08-31 01:20:39] - [INFO] - /mnt/in/2018/07/20180713_130947_D3B693D9.jpg => /mnt/out/2018/07/13/20180713-130947252564.jpg
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_130947_D3B693D9.json => /mnt/out/unknown/20180713_130947_D3B693D9.json
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_162837_1D565480.jpg => /mnt/out/2018/07/13/20180713-162837.jpg
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_162837_1D565480.json => /mnt/out/unknown/20180713_162837_1D565480.json
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_164015_86C6782E.jpg => /mnt/out/2018/07/13/20180713-164015.jpg
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_164015_86C6782E.json => /mnt/out/unknown/20180713_164015_86C6782E.json
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_171837_4104A370.jpg => /mnt/out/2018/07/13/20180713-171837205064.jpg
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_171837_4104A370.json => /mnt/out/unknown/20180713_171837_4104A370.json
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_171912_7AFD55D7.jpg => /mnt/out/2018/07/13/20180713-171912555982.jpg
[2023-08-31 01:20:40] - [INFO] - /mnt/in/2018/07/20180713_171912_7AFD55D7.json => /mnt/out/unknown/20180713_171912_7AFD55D7.json

After, they're handled correctly:

[2023-08-31 01:14:35] - [INFO] - /mnt/in/2018/07/20180713_130947_D3B693D9.jpg => /mnt/out/2018/07/13/20180713-130947252564.jpg
[2023-08-31 01:14:35] - [INFO] - /mnt/in/2018/07/20180713_130947_D3B693D9.json => /mnt/out/2018/07/13/20180713-130947252564.json
[2023-08-31 01:14:35] - [INFO] - /mnt/in/2018/07/20180713_162837_1D565480.jpg => /mnt/out/2018/07/13/20180713-162837.jpg
[2023-08-31 01:14:35] - [INFO] - /mnt/in/2018/07/20180713_162837_1D565480.json => /mnt/out/2018/07/13/20180713-162837.json
[2023-08-31 01:14:35] - [INFO] - /mnt/in/2018/07/20180713_164015_86C6782E.jpg => /mnt/out/2018/07/13/20180713-164015.jpg
[2023-08-31 01:14:35] - [INFO] - /mnt/in/2018/07/20180713_164015_86C6782E.json => /mnt/out/2018/07/13/20180713-164015.json
[2023-08-31 01:14:36] - [INFO] - /mnt/in/2018/07/20180713_171837_4104A370.jpg => /mnt/out/2018/07/13/20180713-171837205064.jpg
[2023-08-31 01:14:36] - [INFO] - /mnt/in/2018/07/20180713_171837_4104A370.json => /mnt/out/2018/07/13/20180713-171837205064.json
[2023-08-31 01:14:36] - [INFO] - /mnt/in/2018/07/20180713_171912_7AFD55D7.jpg => /mnt/out/2018/07/13/20180713-171912555982.jpg

Copy link
Owner

@ivandokov ivandokov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this great PR! There are just a few small notes I left and please add tests for this feature.

src/phockup.py Show resolved Hide resolved
src/phockup.py Show resolved Hide resolved
Currently support exists for handling .xmp sidecars. This change adds
support for arbitrary sidecar extensions. It also expands the set of
sidecars which are handled by default. The new default set, and the
reason this set was chosen, is:

 .xmp - general metadata format for all image types
 .json - generated by google takeout when exporting from g photos
 .yml/.yaml - used by Photoprism

Users can override this default set by passing the new --sidecars
option. For example, to handle .xyz, users should pass

  --sidecars="xmp,json,yml,xyz"
Copy link
Owner

@ivandokov ivandokov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Please add tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants