Tuesday, 4 October 2022

Randomly hex images using open ssl

 


In response to a question in an online diwo ( do it with others) session during this years Fubar https://fubar.space/ I came up with a script that uses openssl to generate random hex numbers which can then be used to glitch the same image over and over but with random values. 

The script is below , its a bit rough and ready and requires that you have imagemagick installed ( on windows via chocolatey) and openssl and run it through git-bash. Note the commented out sections - for linux  it works as is for windows comment out the linux section and uncomment the windows section) - I made a gif from the 23  images generated as proof of concept. 

Try adjusting the values after where hex is written ie  

from=$(openssl rand -hex 1)
  to=$(openssl rand -hex 2)

in each case try different values after the -hex upt to 256 ( equal values in each statement will yield little or no change)

 Script is below ( dont forget to chmod u+x it !!)

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

echo -n "How many iterations (whole number) : "
read n


i=0
#windows
#magick convert $f test.ppm

#linux
convert $f test.ppm

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

 
 from=$(openssl rand -hex 1)
  to=$(openssl rand -hex 2)
 
 
xxd -p test.ppm | sed 's/'$from'/'$to'/g' | xxd -p -r > help.ppm
#windows
#magick convert help.ppm  $i.jpg

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



done


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...