from PIL import Image
print 'Image Decoder/Recreator from xerotic. Original idea from BlueMelon.'
def main():
x = int(raw_input("\n\n1.) Grab content\n2.) Recreate image\n\nChoice: "))
if x == 1:
Decode()
elif x == 2:
Create()
else:
print 'Invalid Choice\n--------------\n'
def Decode():
_name = raw_input("File Name (must be in current directory): ")
txtName = raw_input("Resulting file name: ")
im = Image.open(_name)
im.getcolors()
q = list(im.getdata())
q.insert(0, im.size)
store = open(txtName+".txt", "w")
for i in q:
store.write(str(i)+"\n")
store.close()
def Create():
pix = []
_filename = raw_input("File Name for Image: ")
dataFile = raw_input("Image data file: ")
take = open(dataFile)
for line in take.readlines():
line = line.replace('\n', ''
pix.append(eval(line))
take.close()
h, w = pix.pop(0)
img = Image.new('RGBA',((h,w)))
pixeldata = img.load()
for y in xrange(h):
for x in xrange(w):
i = pix.pop(0)
pixeldata[x,y] = (i)
img.save(_filename+'.png','PNG'
while 1:
main()
Copyright © 2024, NextGenUpdate.
All Rights Reserved.