Skip to content

Instantly share code, notes, and snippets.

@WitherOrNot
Created April 2, 2020 17:06
Show Gist options
  • Save WitherOrNot/26fa4ba6d8a283506eb8d658fbaf150f to your computer and use it in GitHub Desktop.
Save WitherOrNot/26fa4ba6d8a283506eb8d658fbaf150f to your computer and use it in GitHub Desktop.
from PIL import Image, ImageChops
import sys
img = Image.open(sys.argv[1]).convert("RGB")
w, h = img.size
out = Image.new("RGB", (w, h))
def f(x, y):
return ((2*x+y) % w, (x+y) % h)
img.save("frames/0.png")
orig = img
# """
limit = sys.maxsize+1
"""
limit = int(sys.argv[2])+1
# """
for n in range(1, limit):
for i in range(w):
for j in range(h):
out.putpixel(f(i, j), img.getpixel((i, j)))
if ImageChops.difference(orig, out).getbbox() is None:
break
out.save("frames/"+str(n)+".png")
img = out
out = Image.new("RGB", (w, h))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment