Pictures from the array to generate python

 

aa-1.log 
link: https: //pan.baidu.com/s/1bEbXeJtRF792DX0x8TGwhA Password: zwky
 
#coding=utf-8

import time
from PIL import Image
with open("aa-1.log","r") as f:
    costlist=eval(f.read())
img = Image. new new ( " RGB " , ( 675 , 792 )) ### pictures created
print (referred to as (costlist))

single=[]
count=0

output=[]
for i in range(675):
    y=[]
    for j in range(792):
        try:
            if(costlist[count]=="[" or costlist[count]=="]"):
                print(costlist[count])
            x=int(costlist[count])
            #if(x not in single):
                #single.append(x)
            if(x<0):
                pixTuple = (105,105,105,x)
                img.putpixel((i,j),pixTuple)
            elif(x<25):
                pixTuple = (255,255,255,x)
                img.putpixel((i,j),pixTuple)
            elif(x<65):
                pixTuple = (211,211,211,x)
                img.putpixel((i,j),pixTuple)
            else:
                pixTuple = (0,0,0,x)
                img.putpixel((i,j),pixTuple)
            count+=1
            y.append(x)
        except Exception as e:
            print (e, i, j)
    output.append(y)


with open("aa.log","w") as f:
    f.write(str(output).replace("[","{").replace("]","}"))

pixTuple = (255,0,0,0)
img.putpixel((337,300),pixTuple)
img.save("bb.png")
#print(single)

 

Renderings

 

 

 

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11100402.html