swingcut.sh – oscillating cuts
a tiny program that creates mosaics based on a given image. works best with input image width=6×height.
#!/bin/bash ct=0 until [ $ct -gt 719 ] # sets how often a cut will be made (+1) and how many snippets will be produced do ((ct+=1)) # a counter. starting at 1, increasing by 1 ctt=`printf %03d $ct` # prints 3 digits numbers, important for naming the files sw=`awk -v x="$ct" 'BEGIN {wv=sin(2*3.1415926535*(4+(x/100))*(x/10))+0.9999 ; printf wv }'` # defines a sine function. shift 0.9999 above zero on y-axis. cycle duration will change over time mkdir -p cuts # creates a directory for the cut images echo " Cutting … $sw" magick filename.png +profile "icc" -gravity SouthWest -crop "%[fx:(w/20)+0]"x"%[fx:h]"+"%[fx:(w/2.1)*$sw]"+0 +repage cuts/$ctt.png # ImageMagick 7 # cuts the image. the width of the snippets is set as a fraction of the width of the input image. # the position on the x-axis defines where the cut is made. it is calculated with the values of the variable ‘sw’ done while : do echo ' Assembling ! ' montage cuts/*.png -tile 60x -background white -geometry +0+0 -units PixelsPerInch -density 300 newfile.png # composes a new image. with -tile the number of snippets in a row is defined. # it should be a (integer) divisor of ct+1 to avoid gaps at the bottom of the new image break done
CC BY 4.0 – 02/2021