Skip to content

Instantly share code, notes, and snippets.

@bgola
Created August 16, 2014 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgola/63ecd0071db2e021e4b6 to your computer and use it in GitHub Desktop.
Save bgola/63ecd0071db2e021e4b6 to your computer and use it in GitHub Desktop.
glitch
import random
def glitch(jpg):
f = open(jpg, 'r')
new = f.read(400)
for c in f.read():
if random.random() > random.choice([0.9992, 0.9993, 0.9994, 0.9995, 0.9996, 0.9997, 0.9998, 0.9999]):
new += chr(int(ord(c) + random.random()*random.choice(range(100)))%256)
else:
new += c
fw = open("/tmp/glitch_%s", 'w')
fw.write(new)
fw.close()
return "/tmp/glitch_%s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment