diff --git a/media/extollo/README.md b/media/extollo/README.md new file mode 100644 index 0000000..97d1482 --- /dev/null +++ b/media/extollo/README.md @@ -0,0 +1,11 @@ +# Extollo + +This script applies a LUT onto a image/movie file. + +## How to use + +Pass a target file to the runner with a given LUT file: + +```bash +extollo/runner.sh -l path/to/lut.cube path/to/file.mp4 path/to/file.jpg +``` diff --git a/media/extollo/runner.sh b/media/extollo/runner.sh new file mode 100755 index 0000000..fc85465 --- /dev/null +++ b/media/extollo/runner.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# auxiliary functions + +function help() { + echo -e "Usage:\n\t$(basename "$0") -l " +} + +# shell setup + +set -euo pipefail + +# arguments parsing + +LUT="" +TARGETS=() + +while [[ $# -gt 0 ]]; do + case "$1" in + -h | --help) + help + exit 0 + ;; + -l | --lut) + LUT="$2" + shift || echo -n + ;; + *) + TARGETS+=("$1") + ;; + esac + shift || echo -n +done + +# arguments validation + +if [ -z "${LUT}" ]; then + echo "A LUT file must be provided" + exit 1 +fi + +# effective script + +for fname in "${TARGETS[@]}"; do + fname_ext="$(echo "${fname##*.}" | tr '[:upper:]' '[:lower:]' | sed 's/jpeg/jpg/g')" + fname_tmp="/tmp/$(basename "${fname}").$$.${fname_ext}" + + if [ "${fname_ext}" == "jpg" ]; then + gmic "${fname}" "${LUT}" 'map_clut[0]' '[1]' 'o[0]' "${fname_tmp}" + elif [ "${fname_ext}" == "mp4" ]; then + ffmpeg -nostdin -i "${fname}" -vf "lut3d=${LUT},mpdecimate,transpose=2" -c:v libx265 -vtag hvc1 -pix_fmt:v yuv420p -y "${fname_tmp}" + else + echo "Unsupported format ${fname_ext} at ${fname}" + exit 1 + fi + + mv -vf "${fname_tmp}" "${fname}" +done