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

Add support for live photos #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

qlyoung
Copy link
Contributor

@qlyoung qlyoung commented Aug 30, 2023

Look for MediaGroupUUID and ContentIdentifier EXIF tags. These are present in media files which are part of live photo pairs. If found, any future files with the same UUID are named the same as the first one and placed in the same directory.

With this change, live photos and their associated .mov files are moved together.

@ivandokov
Copy link
Owner

Hello @qlyoung. That's wonderful addition to the software. Please add unit tests to the PR and I will happily merge it.

@qlyoung
Copy link
Contributor Author

qlyoung commented Aug 30, 2023 via email

@rob-miller
Copy link
Contributor

@qlyoung Any progress on this? It is a feature I would like to have.

Just a sidenote from spending the morning writing phockup test code: if you are using vscode for development, the pytest fixture is not compatible with addopts = --disable-socket in pytest.ini. That slowed me down for a while.

Look for MediaGroupUUID and ContentIdentifier EXIF tags. These are
present in media files which are part of live photo pairs. If found, any
future files with the same UUID are named the same as the first one and
placed in the same directory.

With this change, live photos and their associated .mov files are moved
together.
@qlyoung
Copy link
Contributor Author

qlyoung commented Nov 17, 2023

No progress on writing tests. I haven't found time to sit down and learn this project's testing setup.

I went ahead and pushed the latest version of this change though, so if you care to build it yourself, the code is in the branch referenced by this PR

@rob-miller
Copy link
Contributor

rob-miller commented Nov 18, 2023

I think this is what's needed:

  def test_process_livephoto(mocker):
      shutil.rmtree('output', ignore_errors=True)
      mocker.patch.object(Phockup, 'check_directories')
      mocker.patch.object(Phockup, 'walk_directory')
      mocker.patch.object(Exif, 'data')
      Exif.data.return_value = {
          "MIMEType": "image/heic",
          "MediaGroupUUID": "492774F4-34F4-4A0E-97E4-69F46D335610"
      }
      phockup = Phockup('input', 'output', move=True)
      open("input/tmp_20170102_010101.HEIC", "w").close()
      open("input/tmp_20170103_010101.MOV", "w").close()
      phockup.process_file("input/tmp_20170102_010101.HEIC")
      Exif.data.return_value = {
          "MIMEType": "video/quicktime",
          "ContentIdentifier": "492774F4-34F4-4A0E-97E4-69F46D335610"
      }
      phockup.process_file("input/tmp_20170103_010101.MOV")
      assert os.path.isfile("output/2017/01/02/20170102-010101.heic")
      assert os.path.isfile("output/2017/01/02/20170102-010101.mov")
      shutil.rmtree('output', ignore_errors=True)

Note that the test highlights that the second file gets renamed to match the first, but I think this is as desired.
Also, I suspect the processing may fail with concurrency enabled.

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

3 participants