Skip to main content

Glitchy GIFs with glitch_this

·387 words·2 mins
Mayke Glitch
Martin Hamilton
Author
Martin Hamilton
Futurist and innovation advisor. ADHD. Hacker. Solarpunk.

OK, so there are lots of apps and websites out there that will let you glitch an image and/or turn a bunch of images into a GIF.

But what if you just wanted to… do it yourself? And in a Unix-y way, with source code, scripting and command line shenanigans?

I came across a great little utility for glitching images called glitch_this, which works on both static images and GIFs.

You can turn a static image into a glitchy GIF with a simple incantation like:

glitch_this -c -g small_bighead.jpg 2

Of course, I glitched myself first of all:

Glitchy GIF of a 3D scan of my head

That went well, and I wondered about how to make a “meta-GIF” that combined several GIFs. It turns out that this is something the venerable ImageMagick image manipulation toolkit can do very easily:

convert file1.gif file2.gif file3.gif newfile.gif

ImageMagick is basically an entire Turing-complete programming environment in a trenchcoat, so you can also get it to apply interesting effects as you go along. There’s a very interesting site called Fred’s ImageMagick Scripts which is probably the motherlode for anyone interested in experimenting with this stuff.

You might find that you want to work with a bunch of images that are slghtly different sizes, and ImageMagick can be very helpful in fixing that, e.g. here we turn an image into a (possibly) smaller version of itself with fixed 320 x 320 resolution:

convert foo.jpg -resize \!320x320 bar.jpg

So if we had a bunch of pictures then we could write a shell script to do something like… resize them all to a consistent size, turn them into glitchy GIFs, and make a combined GIF out of the whole set. Something like this…

for I in IMG*; do
  convert $I -resize \!320x320 small_$I
  glitch_this -c -g -l 1 $I 2
done
convert -delay 1 glitched_small_*gif loopy_goodness.gif

Please note that the GIFs generated by glitch_this will loop indefinitely unless you add the -l parameter to specify the number of loops. And infinitely looping GIFs are tricky to amalgamate…

You might see some glitched meta-GIFs on this site. Oh look, here’s one now 😉

Glitchy GIF of some graffiti art including Delicious Clams in Sheffield

PS One loose end - sometimes the glitched GIF doesn’t load at first, but does if the page is reloaded.