Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
006e37c8a0 | ||
|
|
0bd2cdf589 | ||
|
|
c5ba05b543 | ||
|
|
aa8b8937c0 | ||
|
|
8d26043c93 | ||
|
|
470e49287c | ||
|
|
de6736144b | ||
|
|
bf04dfb46c | ||
|
|
17ff41b63e | ||
|
|
80f871fb20 |
No files matched your search
@@ -0,0 +1 @@
|
||||
__pycache__
|
||||
Binary file not shown.
@@ -6,13 +6,21 @@ 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}'
|
||||
def cat(w, h):
|
||||
url = f'https://cataas.com/cat?width={w}?height={h}?text=cat'
|
||||
resp = urllib.request.urlopen(url)
|
||||
im_data = resp.read()
|
||||
im = Image.open(BytesIO(im_data))
|
||||
return im
|
||||
|
||||
def cat_says(text,w, h):
|
||||
url = f'https://cataas.com/cat/says/{text}?size=100&width={w}?height={h}?text=cat'
|
||||
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)
|
||||
cat = cat(1920,1080)
|
||||
cat.show()
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import string
|
||||
import numpy as np
|
||||
|
||||
def igel():
|
||||
igel = ["aussagend", "fickend", "friedlich-neu", "liebend", "niedlich", "panisch-neu", "peinlich", "schlafend", "unzufrieden", "wissend"]
|
||||
name = np.random.choice(igel)
|
||||
return f'/opt/docker/nextcloud-dockerized/html/data/maya/files/Bilder/=== Freizeit ===/Kunst/Zeichnungen/Igel/{name}.png'
|
||||
return im
|
||||
|
||||
+34
-16
@@ -6,24 +6,31 @@ from itertools import product
|
||||
import string
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from cat import cat
|
||||
from cat import cat, cat_says
|
||||
from igel import igel
|
||||
import argparse
|
||||
|
||||
# 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
|
||||
# parser stuff
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='FluffyPixelfluter',
|
||||
description='used to paint Pixelflut canvas',)
|
||||
parser.add_argument('hostname')
|
||||
parser.add_argument('port')
|
||||
parser.add_argument('-i','--image')
|
||||
parser.add_argument('-r','--random', action='store_true')
|
||||
parser.add_argument('-c','--cat', action='store_true')
|
||||
parser.add_argument('-cs','--catsays')
|
||||
parser.add_argument('-ig','--igel', action='store_true')
|
||||
parser.add_argument('-wd','--width', default=0)
|
||||
parser.add_argument('-ht','--height', default=0)
|
||||
args = parser.parse_args()
|
||||
HOST, PORT = args.hostname, int(args.port)
|
||||
|
||||
# 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"
|
||||
starth = int(args.height)
|
||||
startw = int(args.width)
|
||||
|
||||
rnd = args.random
|
||||
|
||||
# Create a socket (SOCK_STREAM means a TCP socket)
|
||||
# Connect to server and send data
|
||||
@@ -37,6 +44,16 @@ 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 args.cat: im = cat(sizew,sizeh)
|
||||
elif args.catsays: im = cat_says(args.catsays,sizew,sizeh)
|
||||
elif args.igel: im = Image.open(igel())
|
||||
elif args.image: im = Image.open(args.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))))
|
||||
@@ -44,7 +61,8 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
for w in widthlist:
|
||||
if rnd: np.random.shuffle(heightlist)
|
||||
for h in heightlist:
|
||||
color = '#%02x%02x%02x' % pixels[h-starth][w-startw]
|
||||
if pixels[h-starth][w-startw][3] == 0: continue
|
||||
color = '#%02x%02x%02x' % pixels[h-starth][w-startw][0:3]
|
||||
to_send = "px {} {} {}\n".format(w,h,color)
|
||||
sock.sendall(bytes(to_send, "utf-8"))
|
||||
sock.close()
|
||||
|
||||
Reference in new issue
Block a user