Browse Source

initial commit

master
Maya Herrscher 2 years ago
commit
1e9647f781
  1. BIN
      __pycache__/cat.cpython-39.pyc
  2. 18
      cat.py
  3. BIN
      dog.jpg
  4. BIN
      ena-akito.jpg
  5. BIN
      ena.jpg
  6. BIN
      ewe-jona.jpeg
  7. BIN
      ina.jpeg
  8. BIN
      ina.png
  9. BIN
      jonas.jpeg
  10. BIN
      niffler.jpg
  11. 51
      pixelflut.py
  12. BIN
      walid.jpg

BIN
__pycache__/cat.cpython-39.pyc

Binary file not shown.

18
cat.py

@ -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
dog.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
ena-akito.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
ena.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

BIN
ewe-jona.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

BIN
ina.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
ina.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

BIN
jonas.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
niffler.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

51
pixelflut.py

@ -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
walid.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Loading…
Cancel
Save