animation/cmy/cmy.sh

20 lines
455 B
Bash

#!/bin/bash
FILEPATH=`realpath "${1}"`
DIR=`dirname "${FILEPATH}"`
FILENAME=`basename "${FILEPATH}"`
NAME=`echo "${FILENAME}" | cut -d'.' -f1`
EXTENSION="png"
CHANNELS=("c" "m" "y")
convert "${FILEPATH}" \
-negate \
-set colorspace CMYK \
-channel CMY \
-separate \
"${DIR}/${NAME}_%d.${EXTENSION}"
for ((i=0;i<${#CHANNELS[@]};++i)); do
CHANNEL="${CHANNELS[i]}"
mv "${DIR}/${NAME}_${i}.${EXTENSION}" "${DIR}/${NAME}_${CHANNEL}.${EXTENSION}"
done