initial commit
This commit is contained in:
commit
1e9647f781
12 files changed
+69
No files matched your search
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import string
|
||||||
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
import urllib.request
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
def cat(h, w):
|
||||||
|
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__":
|
||||||
|
cat(1920,1080)
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 106 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 692 KiB |
Executable
+51
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
from itertools import product
|
||||||
|
import string
|
||||||
|
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
|
||||||
|
|
||||||
|
# change start point if requested
|
||||||
|
starth, startw = 0, 0
|
||||||
|
if len(sys.argv) > 2: starth = int(sys.argv[2])
|
||||||
|
if len(sys.argv) > 3: startw = int(sys.argv[3])
|
||||||
|
rnd = False
|
||||||
|
if len(sys.argv) > 4: rnd = sys.argv[4] == "rnd"
|
||||||
|
|
||||||
|
# Create a socket (SOCK_STREAM means a TCP socket)
|
||||||
|
# Connect to server and send data
|
||||||
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||||
|
sock.connect((HOST, PORT))
|
||||||
|
|
||||||
|
# query canvas size
|
||||||
|
to_send = "size\n"
|
||||||
|
sock.sendall(bytes(to_send, "utf-8"))
|
||||||
|
received = str(sock.recv(1024), "utf-8")
|
||||||
|
sizew = int(received.split(" ")[1])
|
||||||
|
sizeh = int(received.split(" ")[2])
|
||||||
|
|
||||||
|
# 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))))
|
||||||
|
if rnd: np.random.shuffle(widthlist)
|
||||||
|
for w in widthlist:
|
||||||
|
if rnd: np.random.shuffle(heightlist)
|
||||||
|
for h in heightlist:
|
||||||
|
color = '#%02x%02x%02x' % pixels[h-starth][w-startw]
|
||||||
|
to_send = "px {} {} {}\n".format(w,h,color)
|
||||||
|
sock.sendall(bytes(to_send, "utf-8"))
|
||||||
|
sock.close()
|
||||||
|
print("finished")
|
||||||
Reference in new issue
Block a user