#!/usr/bin/env bash
# Author: Jens Steidl
# SLUB Dresden, Department Longterm Preservation
# copyright 2023, licensed under terms of GNU General Public License 3.0,
# see file LICENSE.txt for details.
### META
# AUTHORS:
#  - Jens Steidl (<Jens.Steidl@slub-dresden.de>)

if [[ $# -eq 0 ]]; then
    echo "No file path supplied."
    exit 1;
fi
FILE="$1"
if ! [[ -f "${FILE}" ]]; then
    echo "File '${FILE}' does not exist."
    exit 1;
fi

TOOL_OUTPUT=$(/usr/local/bin/iccDumpProfile -v "${FILE}")
echo "${TOOL_OUTPUT}"

# exit code
#   0 -> valid icc file
#   1 -> invalid icc file
echo ${TOOL_OUTPUT} | grep -v "Profile violates ICC specification" > /dev/null