5x5のタイル状にしてみた。
好みの夕暮れの色があるように、好みのノイズ量があるに違いないので、もう少しノイズの入れ方を考えないと。
import base64,re,Image
from random import randint
def glitch(infile,outfile):
jpg_text = base64.encodestring(open(infile,"rb").read())
glitched_text = ""
count = 0
width,height = Image.open(infile).size
num = width * height / 10000
for c in jpg_text:
if c == '0':
if randint(0,num) == 0:
count += 1
glitched_text += str(randint(0,9))
else:
glitched_text += c
else:
glitched_text += c
glitched_jpg = base64.decodestring(glitched_text)
open(outfile,"wb").write(glitched_jpg)
return count
if __name__ == '__main__':
for i in range(25):
outfile = "test_%d.jpg" % i
count = glitch("/Users/kzfm/yuki3.jpg",outfile)
#print "%d: %d" % (i,count)
tiled_im = Image.new('RGB',(1600,1200))
tiled_px = tiled_im.load()
for i in range(5):
for j in range(5):
n = 5*i+j;
imgfile = "/Users/kzfm/python/test_%d.jpg" % n
im = Image.open(imgfile)
px = im.load()
for x in range(320):
for y in range(240):
nx = 320 * j + x
ny = 240 * i + y
tiled_px[nx,ny] = px[x,y]
tiled_im.show()