Department of Physics and Astronomy

The Forbes Group

Photos and Git Annex

$\newcommand{\vect}[1]{\mathbf{#1}} \newcommand{\uvect}[1]{\hat{#1}} \newcommand{\abs}[1]{\lvert#1\rvert} \newcommand{\norm}[1]{\lVert#1\rVert} \newcommand{\I}{\mathrm{i}} \newcommand{\ket}[1]{\left|#1\right\rangle} \newcommand{\bra}[1]{\left\langle#1\right|} \newcommand{\braket}[1]{\langle#1\rangle} \newcommand{\op}[1]{\mathbf{#1}} \newcommand{\mat}[1]{\mathbf{#1}} \newcommand{\d}{\mathrm{d}} \newcommand{\pdiff}[3][]{\frac{\partial^{#1} #2}{\partial {#3}^{#1}}} \newcommand{\diff}[3][]{\frac{\d^{#1} #2}{\d {#3}^{#1}}} \newcommand{\ddiff}[3][]{\frac{\delta^{#1} #2}{\delta {#3}^{#1}}} \DeclareMathOperator{\erf}{erf} \DeclareMathOperator{\Tr}{Tr} \DeclareMathOperator{\order}{O} \DeclareMathOperator{\diag}{diag} \DeclareMathOperator{\sgn}{sgn} \DeclareMathOperator{\sech}{sech} $

Photos and Git-Annex

In this post we discuss using git-annex to manage photos.

Google Photos and Google Drive

Through the Google Drive settings, one can choose to "Create a Google Photos folder". This will create a folder call "Google Photos" in your drive that you can use to manage photos. After playing with this, it does not seem like you can add photos by adding them to folders on Google Drive... it only mirrors what is in Google Photos. You can delete photos from Google Drive though.

(Note: through the Google Photo settings one can choose to allow Google Photo to access all photo-like objects in your Google Drive, but this does not seem to allow for any control.)

Attempt 1: 25 Aug 2018

This describes our first attempt.

  • Create a bitbucket project (git) to store the metadata online.

  • Clone to a folder on an external hard drive.

    cd /Volumes/Data\ WD2TB
    git clone [email protected]:mforbes/photolibrarymfkb.git MFKBPhotoLibrary
    cd MFKBPhotoLibrary
    
  • Initialize git-annex:

    git annex init
    

    This gives the following warning:

    Remote origin does not have git-annex installed; setting annex-ignore
    

    This is fine: Bitbucket does not have git annex, but we are only using it for the git portion. This just means that non of the content (i.e. the actual photos) will be stored there.

  • Add README.md file describing things.

    git add README.md
    git commit -m "Added README.md file"
    git push
    
  • Make some folder and add photos.

    mkdir -p Library/2018
    rsync -av /Volumes/NO\ NAME/DCIM/169___06/ \
            Library/2018/CanonPowerShotELPH500HS/169___06/
    rsync -av /Volumes/NO\ NAME/DCIM/170___08 \
            Library/2018/CanonPowerShotELPH500HS/
    
  • Add the photos with git annex and commit.

    git annex add Library
    git commit -m "Added photos from Cannon (2016-2018) with git annex"
    

Photos (Mac App)

To work with the Photos App (Mac OS X), you must have the actual files, not symlinks. To do this with git annex, you must unlock the files first.

git annex unlock Library/2018/CanonPowerShotELPH500HS

This will copy the photos to the directory allowing you to work with them, but copying the photos can take a long time, so you might want to set the annex.thin option to True to use hard-links. Note however, that this is dangerous, because now you can edit the photo, possibly corrupting it.

  • To select a new Library when opening Photos, hold down the option key.
  • Our convention is to de-select "Copy Photos" from the Preferences and to keep the original folder structure upon import. This way the photos should stay in their original place unless you edit them with Photos.
In [ ]: