forked from joey-kilgore/PyFarm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratePhoto.py
More file actions
38 lines (30 loc) · 1.01 KB
/
Copy pathGeneratePhoto.py
File metadata and controls
38 lines (30 loc) · 1.01 KB
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
30
31
32
33
34
35
36
37
# Test script that will use Pillow to generate photos
from PIL import Image
import random
import numpy as numpy
import PyFarm
import base64
from io import BytesIO
numberOfImages = int(PyFarm.input(0))
#arr = numpy.random.randint(0,255,(100,100,3),dtype='uint8') #Pillow interprets type as uint8, not int32
#print(arr)
#im = Image.fromarray(arr, 'RGB')
#im.show()
for num in range(0,numberOfImages):
im = Image.new('RGBA',(400,400))
pixels = im.load()
for x in range(im.size[0]):
for y in range(im.size[1]):
pixels[x, y] = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), random.randint(0,255))
im.show()
buffered = BytesIO()
im.save(buffered, format="PNG")
imb64 = base64.b64encode(buffered.getvalue())
#print(imb64)
PyFarm.output(str(imb64)[1500:1600])
#im = Image.new('RGB',(100,100))
#pixels = im.load()
#for x in range(im.size[0]):
# for y in range(im.size[1]):
# pixels[x, y] = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
#im.show()