#! /bin/sh
# This script tests: pamrecolor
# Also requires: ppmtopgm pgmmake

tmpdir=${tmpdir:-/tmp}
base_pgm=${tmpdir}/base.pgm

pgmmake 0.5 230 150 > ${base_pgm}

echo "Test 1. Should produce 3500040755 101532"

pamrecolor --colorfile=${base_pgm} testimg.ppm | cksum

echo "Test 2. Should produce 3500040755 101532 twice"

pamrecolor --targetcolor=rgb:80/80/80 testimg.ppm | cksum
pamrecolor --colorspace=ntsc --targetcolor=rgb:80/80/80 testimg.ppm | cksum

. ./test-invalid.inc

truncated_file=${tmpdir}/truncated.txt
echo P6 > ${truncated_file}

invCmd "pamrecolor --targetcolor=rgb:00/11/22 --colorfile=${base_pgm} testimg.ppm"
invCmd "pamrecolor --rmult=0.3  --gmult=0.3  --bmult=0.3 --colorfile=${base_pgm} testimg.ppm"
invCmd "pamrecolor --colorspace=void --targetcolor=rgb:80/80/80 testimg.ppm"
invCmd "pamrecolor --targetcolor=vague testimg.ppm"
invCmd "pamrecolor --colorfile=${truncated_file} testimg.ppm"
invCmd "pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm"

rm ${base_pgm} ${truncated_file}
