└── autoscan.sh /autoscan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -euo pipefail 4 | 5 | if [ -z "$1" ]; then 6 | target="$(pwd)" 7 | else 8 | target="$1" 9 | fi 10 | 11 | if ! [ -d "$target" ]; then 12 | echo "Error: $target is not a directory!" 13 | exit 1 14 | fi 15 | 16 | AUTOSCAN_IT8_VALUES="${AUTOSCAN_IT8_VALUES=${HOME}/Pictures/IT8/R200209.txt}" 17 | AUTOSCAN_SCANNER_NAME="${AUTOSCAN_SCANNER_NAME=ScanJet 5590}" 18 | 19 | it8_path="$target/it8.tiff" 20 | alt_it8_path="$target/it8.tif" 21 | it8_scan="$it8_path" 22 | if ! [ -f "$it8_scan" ]; then 23 | it8_scan="$alt_it8_path" 24 | 25 | if ! [ -f "$it8_scan" ]; then 26 | echo "Error: couldn't find an IT8 scan!" 27 | echo "Checked \`$it8_path\` and \`$alt_it8_path\`" 28 | exit 1 29 | fi 30 | fi 31 | 32 | it8_scan_base="$(echo "$it8_scan" | sed -E 's,.tiff?$,,')" 33 | 34 | cd "$target" 35 | 36 | today="$(date "+%Y-%m-%d")" 37 | 38 | # Produce an Argyll-format data file based on the readings in the chart 39 | scanin -v "$it8_scan" "$(brew --prefix argyll-cms)/ref/it8.cht" "$AUTOSCAN_IT8_VALUES" 40 | # Transform Argyll's .ti3 into a .icc 41 | colprof -v -D"${AUTOSCAN_SCANNER_NAME} ${today}" -qm -as "$it8_scan_base" 42 | 43 | icc_path="${it8_scan_base}.icc" 44 | mkdir -p profiled 45 | 46 | # Create copies of each TIFF with the ICC embedded 47 | for scan in *.tif*; do 48 | base="$(basename "$scan")" 49 | convert "$scan" -profile "$icc_path" profiled/$base 50 | done 51 | --------------------------------------------------------------------------------