Created
April 22, 2019 21:25
-
-
Save serid/47722c5d78fbefe5aa6af5ef32e0af30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This program shuffles pixels in input.jpg and spits them out to output.jpg | |
### | |
### Pretty easy huh? | |
from PIL import Image | |
from random import shuffle | |
def main(): | |
im = Image.open("input.jpg") | |
x, y = im.size | |
px = im.load() | |
pxarr = [] | |
for i in range(y): | |
for j in range(x): | |
pxarr.append(px[j,i]) | |
shuffle(pxarr) | |
for i in range(y): | |
for j in range(x): | |
px[j,i] = pxarr[i * x + j] | |
#im.show() | |
im.save("output.jpg") | |
pass | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment