Use exiv2 for metadata handling
This commit is contained in:
@@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This Bash4 script generates lens ID and other parameter lists for rtexif/*.cc
|
||||
# using ExifTool. It uses xmlstarlet to parse ExifTool's output.
|
||||
#
|
||||
# Run the script from the project root:
|
||||
# ./tools/generateRtexifUpdates
|
||||
#
|
||||
# Manually replace old code in rtexif/* with new from /tmp/rt-generateRtexifUpdates/*
|
||||
#
|
||||
# Blame DrSlony
|
||||
# Please report bugs or enhancements to https://github.com/Beep6581/RawTherapee
|
||||
|
||||
et="$HOME/programs/code-exiftool/exiftool"
|
||||
|
||||
hash "$et" 2>/dev/null || { echo >&2 "ExifTool not found, install it first."; exit 1; }
|
||||
hash xmlstarlet 2>/dev/null || { echo >&2 "XMLStarlet not found, install it first."; exit 1; }
|
||||
|
||||
unset cam cams
|
||||
|
||||
tmpdir="/tmp/rt-generateRtexifUpdates"
|
||||
|
||||
printf '%s\n' "ExifTool version: $("$et" -ver)" "" "XMLStarlet version: $(xmlstarlet --version)" | sed 's/^/# /'
|
||||
|
||||
if [[ -d ${tmpdir} ]]; then
|
||||
printf '%s\n' "" "Must remove temp folder from previous run: $tmpdir"
|
||||
rm -rvI "$tmpdir" || exit 1
|
||||
fi
|
||||
mkdir -p "$tmpdir" || { printf '%s\n' "Error creating $tmpdir" ""; exit 1; }
|
||||
echo
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Canon
|
||||
printf '%s\n' "Saving ${tmpdir}/canon_lenses"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon_lenses"
|
||||
|
||||
#In :10.1 Sigma 50mm f/2.8 EX
|
||||
#Out: {10, "Sigma 50mm f/2.8 EX"},
|
||||
# delete lines matching '-1<tab>n/a'
|
||||
# replace '10.1<tab>Sigma' with '10, "Sigma'
|
||||
# prepend whitespace
|
||||
# append closing braces
|
||||
# replace ' F/11' with ' f/11'
|
||||
sed -r -i \
|
||||
-e '/-1\tn\/a/d' \
|
||||
-e 's/([0-9]+)[0-9.]*\t/\1, "/' \
|
||||
-e 's/^/ {/' \
|
||||
-e 's/$/"},/' \
|
||||
-e 's| F/([0-9]+)| f/\1|' \
|
||||
"${tmpdir}/canon_lenses"
|
||||
|
||||
#In :16842752 PowerShot A30
|
||||
#Out: choices[16842752] = "PowerShot A30";
|
||||
# prepend whitespace and 'choices['
|
||||
# replace <tab> with '] = "'
|
||||
# append '";'
|
||||
printf '%s\n' "Saving ${tmpdir}/canon_cameras"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='CanonModelID']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon_cameras"
|
||||
sed -r -i \
|
||||
-e 's/^/ choices[/' \
|
||||
-e 's/\t/] = "/' \
|
||||
-e 's/$/";/' \
|
||||
"${tmpdir}/canon_cameras"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Nikon LensIDs are composite tags
|
||||
printf '%s\n' "Saving ${tmpdir}/nikon"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensID']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -composite:all) > "${tmpdir}/nikon"
|
||||
sed -r -i -e '/^... /d' -e 's/^/ {"/' -e 's/([A-F0-9]+)[A-F0-9.]*\t/\1", "/' -e 's/$/"},/' -e 's|(.* ")(.*) F([0-9]+)|\1\2 f/\3|' -e 's| F/([0-9]+)| f/\1|' "${tmpdir}/nikon"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Olympus
|
||||
printf '%s\n' "Saving ${tmpdir}/olympus"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -olympus:all) | sort -fuV > "${tmpdir}/olympus"
|
||||
sed -r -i -e '/0 00 00\tNone/d' -e 's/^/ lenses["0/' -e 's/\t/"] = "/' -e 's/$/";/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/olympus"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Pentax
|
||||
printf '%s\n' "Saving ${tmpdir}/pentax"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -pentax:all) | sort -fuV > "${tmpdir}/pentax"
|
||||
sed -r -i -e 's/^/ choices.insert (p_t (256 * /' -e 's/([0-9]+) ([0-9]+)([0-9.]*)/\1 + \2/' -e 's/\t/, "/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|' "${tmpdir}/pentax"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Sony
|
||||
printf '%s\n' "Saving ${tmpdir}/sony"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony"
|
||||
# Sony has more lenses under the LensType2 tag
|
||||
printf '%s\n' "Saving ${tmpdir}/sony-lenstype2"
|
||||
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType2']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony-lenstype2"
|
||||
sed -r -i -e 's/^/ {/' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/$/"},/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony"
|
||||
sed -r -i -e '/255\tTamron Lens (255)/d' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/^/ choices.insert (p_t (/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony-lenstype2"
|
||||
|
Reference in New Issue
Block a user