#/bin/sh

TEMP=${AUTOPKGTEST_TMP:-${TMPDIR:-$(mktemp -d)}}
TDIR=$(mktemp -d $TEMP/test-separate-1-XXXXXX)

convert /usr/share/wallpapers/EveningGlow/contents/images/2560x1440.jpg -resize '640x480!' "$TDIR"/origin.jpg

sleep 1

echo "Run separate+..."
gimp-console -i -b "(let* ((i1 (car (gimp-file-load 1 \"$TDIR/origin.jpg\" \"$TDIR/origin.jpg\"))) (layer1 (car (gimp-image-get-active-layer i1))) (cmykimg (car (plug-in-separate-full 1 i1 layer1 \"/usr/share/color/icc/colord/SMPTE-C-RGB.icc\" FALSE \"/usr/share/color/icc/ghostscript/gray_to_k.icc\" 1 FALSE FALSE FALSE FALSE)))) (gimp-xcf-save 1 cmykimg (car (gimp-image-get-active-drawable cmykimg)) \"$TDIR/output.xcf\" \"$TDIR/output.xcf\") (gimp-quit 1))"

sleep 2

if [ ! -e "$TDIR"/output.xcf ]; then
   echo "No output.xcf"
   exit 404
fi
