cmyk script for separating channels from an RGB file for printing

This commit is contained in:
mattmcw 2021-04-05 10:40:22 -04:00
parent 26fda5e05a
commit c66fda9c9b
1 changed files with 29 additions and 0 deletions

29
cmyk.sh Normal file
View File

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