Skip to content

Instantly share code, notes, and snippets.

@dmpop
Last active March 24, 2017 06:00
Show Gist options
  • Save dmpop/55ecb0d67e21016f36e0 to your computer and use it in GitHub Desktop.
Save dmpop/55ecb0d67e21016f36e0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# DESCRIPTION
# -----------
# The xml2exif Bash shell script extracts aperture, shutter speed, and ISO from an XML file generated by
# the Photographer's Notebook app (https://play.google.com/store/apps/details?id=unisiegen.photographers.activity)
# and writes the obtained values into the specified photo.
# DEPENDENCIES
# ------------
# XMLStarlet
# ExifTool
# To install the required packages on Debian and Ubuntu, run the following command as root:
# apt-get install xmlstarlet libimage-exiftool-perl
# USAGE
# -----
# ./xml2exif.sh [frame number] [XML file] [photo]
# Example:
# ./xml2exif.sh 17 0001.xml foo.jpg
# Obtain aperture, shutter speed, and ISO values for a specific frame
EXPOSURE_TIME=$(xmlstarlet sel -t -v 'Film/Bilder/Bild[Bildnummer="Picture '$1'"]/Zeit' $2)
FNUMBER=$(xmlstarlet sel -t -v 'Film/Bilder/Bild[Bildnummer="Picture '$1'"]/Blende' $2)
ISO_STR=$(xmlstarlet sel -t -v 'Film/Empfindlichkeit' $2)
# Extract the actual ISO value
ISO_NUM=${ISO_STR:4}
ISO=${ISO_NUM%/*}
# Write the obtained values into the specified photo
exiftool -exposuretime=$EXPOSURE_TIME $3
exiftool -fnumber=$FNUMBER $3
exiftool -iso=$ISO $3
echo "All done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment