initial commit

This commit is contained in:
Maya Herrscher committed 2023-10-10 11:27:22 +02:00
commit 1e9647f781
12 files changed
+69

No files matched your search

Binary file not shown.
Executable
+18
View File
@@ -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)
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

Executable
+51
View File
@@ -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")
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB