blob: 167aa74e102d327ff1b6c0ed468efcff8360293d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/env python3
import sys
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
def get_base_image(image):
image = Image.fromarray(np.uint8(image))
image = image.convert(mode="RGBA", colors=256)
if image.size != (640, 480): # width, height
image = image.resize(size=(640, 480))
return image
def show_image(image):
plt.imshow(image)
plt.show()
image = get_base_image(eval(input("")))
image_bytes = image.tobytes()
#show_image(image)
out_file, = sys.argv[1:]
with open(out_file, 'wb') as f:
f.write(image_bytes)
|