Scripts for separating images into cmy (negative) and then stitching back together render files

This commit is contained in:
Matt McWilliams 2021-08-03 20:34:38 -04:00
parent d3a6a88109
commit c34c2e3b6d
3 changed files with 91 additions and 0 deletions

20
cmy/cmy.sh Normal file
View File

@ -0,0 +1,20 @@
#!/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

40
cmy/combine.sh Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash
FILEPATH=`realpath "${1}"`
DIR=`dirname "${FILEPATH}"`
FILENAME=`basename "${FILEPATH}"`
NAME=`echo "${FILENAME}" | cut -d'.' -f1`
EXTENSION="png"
CHANNELS=("c" "m" "y")
OUTPUT="${DIR}/${NAME}_cmy.${EXTENSION}"
CYAN="${DIR}/${NAME}_c.${EXTENSION}.rendered.${EXTENSION}"
MAGENTA="${DIR}/${NAME}_m.${EXTENSION}.rendered.${EXTENSION}"
YELLOW="${DIR}/${NAME}_y.${EXTENSION}.rendered.${EXTENSION}"
WIDTH=404
HEIGHT=374
convert -size "${WIDTH}x${HEIGHT}" xc:rgb\(0,255,255\) cyan.png
convert -size "${WIDTH}x${HEIGHT}" xc:rgb\(255,0,255\) magenta.png
convert -size "${WIDTH}x${HEIGHT}" xc:rgb\(255,255,0\) yellow.png
composite -colorspace RGB -compose screen "${CYAN}" cyan.png cyan_comp.png
composite -colorspace RGB -compose screen "${MAGENTA}" magenta.png magenta_comp.png
composite -colorspace RGB -compose screen "${YELLOW}" yellow.png yellow_comp.png
composite -colorspace RGB -compose multiply yellow_comp.png cyan_comp.png 1.png
composite -colorspace RGB -compose multiply 1.png magenta_comp.png "${OUTPUT}"
rm cyan.png
rm magenta.png
rm yellow.png
#rm cyan_comp.png
#rm magenta_comp.png
#rm yellow_comp.png
#rm 1.png
mogrify -negate "${OUTPUT}"
open "${OUTPUT}"

31
cmy/stipple.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
INPUT=`realpath "${1}"`
PNG="${INPUT}.rendered.png"
SVG="${INPUT}.rendered.svg"
WIDTH=404
HEIGHT=374
DOTSIZE=4
MAXGENERATIONS=25
MAXPARTICLES=750
MINDOTSIZE=0.8
LINE=0.8
FILL=true
cd ~/src/stipple_gen/
bash stipple_gen.sh \
--inputImage "${INPUT}" \
--outputImage "${PNG}" \
--outputSVG "${SVG}" \
--canvasWidth $WIDTH \
--canvasHeight $HEIGHT \
--dotSizeFactor $DOTSIZE \
--windowWidth $WIDTH \
--windowHeight $HEIGHT \
--maxGenerations $MAXGENERATIONS \
--minDotSize $MINDOTSIZE \
--line $LINE \
--fill $FILL \
--maxParticles $MAXPARTICLES