This is a script for windows ( using git-bash terminal and with imagemagick installed) to glitch images in batches of 3 and then makes those images into a single gif - it copies the original source files into a folder called originals to keep them safe, then moves each batch of three files into the frames folder , glitches them then creates a gif from them then dletes the original images - it does this until images in directory where script is running from are gone !! A work in progress use at your peril .
#! /bin/bash
#make directory to hold output
h=$(pwd)
echo $h
mkdir $h/frames
mkdir $h/originals
echo -n "Source image format ? : "
read f
cp *.$f $h/originals/
i=$(ls *.$f | wc -l)
echo $i
echo -n "Image format to use ? : "
read t
#for loop should go here
while [ $i -gt 0 ]
do
d=$(date +%Y-%m-%d_%H%M%S)
#move three files to $h/frames with find
find . -maxdepth 1 -name '*.'$f'' | head -n 3 | xargs -d $'\n' mv -t $h/frames/
cd $h/frames/
magick mogrify -format $t *.$f
find . -type f -name '*.'$t''|while read filename; do echo ${filename};
#do the random number thing
#generate no from 1 to 16
sugar1=$(( $RANDOM % 16 + 1 ))
sugar3=$(( $RANDOM % 16 + 1 ))
sugar2=$(( $RANDOM % 16 + 2 ))
sugar4=$(( $RANDOM % 16 + 2 ))
#convert to hex
from=$(printf '%x\n' $sugar1)
to=$(printf '%x\n' $sugar2)
from2=$(printf '%x\n' $sugar3)
to2=$(printf '%x\n' $sugar4)
magick convert -resize 640x640\! ${filename} test.$t
xxd -p test.$t| sed -b '5,$s/'"$from""$from2"/"$to""$to2"'/g' | xxd -p -r > ${filename};
done
magick convert -delay 20 -loop 0 *.$t $d.gif
rm *.$f
rm *.$t
cd $h
i=$((i-=3))
#cd $h/frames/
done