Files
homelab/infrastructure/graduated/ios/README.md

2.4 KiB

iOS

Photos Export

https://github.com/icloud-photos-downloader/icloud_photos_downloader

podman run -it --rm --name icloudpd \
    -v $(pwd)/iPhotos:/data \
    -e TZ=America/New_York \
    icloudpd/icloudpd:latest \
    icloudpd \
        --directory /data \
        --username apple@ducoterra.net \
        --watch-with-interval 3600

You can browse all downloaded photos with feh:

pacman -S feh

feh --recursive --scale-down -d -S filename $(pwd)/iPhotos

Extensions

  • PNG
  • HEIC: iOS HDR photo
  • MOV
  • DNG: iOS raw photo
  • JPG
  • 3gp: quicktime video file
  • MP4
  • GIF
  • WEBP: Google photo container
  • CR2: Canon raw photo

Conversion

You will need imagemagick and libraw:

pacman -S imagemagick libraw

Then you can convert any image with magick:

magick input.HEIC output.png
magick input.HEIC output.jpeg

You get a list of all unique file extensions with:

find . -type f | awk -F. '!a[$NF]++{print $NF}'

Then use those file extensions to create a find command:

# -o means "or" in this case
# Parentheses are required
find . -type f -printf '%p\n' \( \
    -iname '*.jpg' \
    -o -iname '*.heic' \
    -o -iname '*.dng' \
    -o -iname '*.png' \
    -o -iname '*.WEBP' \
    -o -iname '*.cr2' \
\)

And then use xargs with magick to convert the images:

find . -type f \( \
    -iname '*.jpg' \
    -o -iname '*.heic' \
    -o -iname '*.dng' \
    -o -iname '*.png' \
    -o -iname '*.WEBP' \
    -o -iname '*.cr2' \
\) -print0 | xargs -0 -P $(nproc) -I % python -c "\
import subprocess; \
from pathlib import Path; \
to_folder = '/run/media/ducoterra/photos/'; \
p = Path(\"%\"); \
realpath = (str(p.parent) + '/' if str(p.parent) != '.' else '') + p.stem + '.jpg'; \
subprocess.run(['mkdir', '-p', to_folder + str(Path(realpath).parent)]); \
subprocess.run(['magick', \"%\", to_folder + realpath])"

And then videos:

find . -type f \( \
    -iname '*.MOV' \
    -o -iname '*.3gp' \
    -o -iname '*.MP4' \
    -o -iname '*.GIF' \
\) -print0 | xargs -0 -I % python -c "\
import subprocess; \
from pathlib import Path; \
to_folder = '/run/media/ducoterra/photos/'; \
p = Path(\"%\"); \
realpath = (str(p.parent) + '/' if str(p.parent) != '.' else '') + p.stem + '.mp4'; \
subprocess.run(['mkdir', '-p', to_folder + str(Path(realpath).parent)]); \
subprocess.run(['ffmpeg', '-i', '%', '-c', 'copy', to_folder + realpath])"