Thursday, 6 October 2022

Gifatron - automated hexed gifs from one image.

 

This script is a modification of the previous post . It doesnt just glitch a single image randomly using openssl it also outputs those images as a gif . Its tuned more for Tumblr which has a 10mb limit on gifs , it also downsizes the input picture if need be to 640x480 .

On both windows and linux you will need imagemagick installed, on Windows 10 I'd advise installing the version available from the imagemagick website over installing via chocolatey ( from here https://imagemagick.org/script/download.php )plus you will also need git-bash terminal installed,  this will not work in windows powershell!! When asked for no of iterations 5 is probably best to keep down the size. Save the script below as a file with .sh extension and dont forget to make it executable - on linux chmod u+x uncomment the linux bits and comment out the windows bits . This also does some trickery with headers ( I'm converting the input file to pam and then storing the header, stripping it, then adding it back after glitching - it helps stop the file becoming unreadable - doesnt work everytime note so you will see error messages at some point.

Also remember to delete the jpgs created by the process afterwards or they get mixed back into the next gif you make , which you might want but it does make the file bigger !! ( see previous post for description of how to alter random hex generation)

#! /bin/bash
echo -n "name of image ? : "
read f

echo -n "How many iterations (whole number) : "
read n
i=0
#windows
magick convert -resize 640x480\! $f test.pam

#linux
#resize info here https://imagemagick.org/Usage/resize/#resize
#convert -resize 640x480\! $f test.pam

while [ $i -lt $n ]
do
    ((i++))

 #get header
  sed '2,$d' test.pam > head.pam;

#strip header ( to avoid damaging it)
  sed -b '1d'  test.pam > swap.pam
 from=$(openssl rand -hex 1)
  to=$(openssl rand -hex 2)
 
xxd -p swap.pam | sed 's/'$from'/'$to'/g' | xxd -p -r > help.pam

#put the header back
cat head.pam help.pam> headswap.pam;

#windows
magick convert headswap.pam  $i.jpg

#linux
#convert headswap.pam image-00$i.jpg
rm help.pam

done
#morphgif
#windows
magick convert -delay 5 *.jpg -morph 14  gifatron-$from-$to.gif
#linux
#convert -delay 5 *.jpg -morph 14  gifatron-$from-$to.gif


Mark Fisher – ‘Ghosts of my life’, Fukuyama’s ‘End of history’ and rebooting the future with glitch art.

Note- this was the introduction I gave during a recent online discussion with Verena Voigt ( https://www.verena-voigt-pr.de/ ) a...