Add random cat images (untested!!)
This commit is contained in:
1 parent
1e9647f781
commit
80f871fb20
3 files changed
+12
-9
No files matched your search
Binary file not shown.
@@ -6,12 +6,11 @@ from PIL import Image
|
||||
import urllib.request
|
||||
from io import BytesIO
|
||||
|
||||
def cat(h, w):
|
||||
def cat(w, h):
|
||||
url = f'https://cataas.com/cat?width={w}&height={h}'
|
||||
resp = urllib.request.urlopen(url)
|
||||
im_data = resp.read()
|
||||
im = Image.open(BytesIO(im_data))
|
||||
im.show()
|
||||
return im
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+11
-7
@@ -8,13 +8,6 @@ import numpy as np
|
||||
from PIL import Image
|
||||
from cat import cat
|
||||
|
||||
# open image to be sent
|
||||
image = sys.argv[1]
|
||||
im = Image.open(image)
|
||||
|
||||
pixels = list(im.getdata())
|
||||
width, height = im.size
|
||||
pixels = [pixels[i * width:(i + 1) * width] for i in range(0,height)]
|
||||
|
||||
HOST, PORT = "px.oeinf.de", 1234
|
||||
|
||||
@@ -37,6 +30,17 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
sizew = int(received.split(" ")[1])
|
||||
sizeh = int(received.split(" ")[2])
|
||||
|
||||
# open image to be sent or query a cat image
|
||||
if sys.argv[1] == 'cat':
|
||||
im = cat(sizew,sizeh)
|
||||
else:
|
||||
image = sys.argv[1]
|
||||
im = Image.open(image)
|
||||
|
||||
pixels = list(im.getdata())
|
||||
width, height = im.size
|
||||
pixels = [pixels[i * width:(i + 1) * width] for i in range(0,height)]
|
||||
|
||||
# create list of stuff and shuffle if requested
|
||||
widthlist = list(range(0 + startw,min(int(sizew),(width+startw))))
|
||||
heightlist = list(range(0 + starth, min(int(sizeh),(height+starth))))
|
||||
|
||||
Reference in new issue
Block a user