Compare commits

..
6 Commits
Author SHA1 Message Date
root 006e37c8a0 Fix opacity stuff 2023-10-12 15:57:31 +02:00
Maya Herrscher 0bd2cdf589 Add random igel functionality 2023-10-12 15:52:21 +02:00
Maya Herrscher c5ba05b543 fix errors 2023-10-10 22:20:43 +02:00
Maya Herrscher aa8b8937c0 Add cat says stuff (untested) 2023-10-10 16:36:36 +02:00
Maya Herrscher 8d26043c93 Change cat says 2023-10-10 15:32:31 +02:00
Maya Herrscher 470e49287c Fix trouble with pngs 2023-10-10 15:13:54 +02:00
3 changed files with 29 additions and 5 deletions

No files matched your search

+9 -1
View File
@@ -7,7 +7,14 @@ import urllib.request
from io import BytesIO from io import BytesIO
def cat(w, h): def cat(w, h):
url = f'https://cataas.com/cat/says/DOCHKATZE?size=100&width={w}?height={h}?text=cat' 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) resp = urllib.request.urlopen(url)
im_data = resp.read() im_data = resp.read()
im = Image.open(BytesIO(im_data)) im = Image.open(BytesIO(im_data))
@@ -16,3 +23,4 @@ def cat(w, h):
if __name__ == "__main__": if __name__ == "__main__":
cat = cat(1920,1080) cat = cat(1920,1080)
cat.show() cat.show()
Executable
+11
View File
@@ -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
+9 -4
View File
@@ -6,7 +6,8 @@ from itertools import product
import string import string
import numpy as np import numpy as np
from PIL import Image from PIL import Image
from cat import cat from cat import cat, cat_says
from igel import igel
import argparse import argparse
# parser stuff # parser stuff
@@ -18,10 +19,11 @@ parser.add_argument('port')
parser.add_argument('-i','--image') parser.add_argument('-i','--image')
parser.add_argument('-r','--random', action='store_true') parser.add_argument('-r','--random', action='store_true')
parser.add_argument('-c','--cat', 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('-wd','--width', default=0)
parser.add_argument('-ht','--height', default=0) parser.add_argument('-ht','--height', default=0)
args = parser.parse_args() args = parser.parse_args()
HOST, PORT = args.hostname, int(args.port) HOST, PORT = args.hostname, int(args.port)
# change start point if requested # change start point if requested
@@ -44,7 +46,9 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
# open image to be sent or query a cat image # open image to be sent or query a cat image
if args.cat: im = cat(sizew,sizeh) if args.cat: im = cat(sizew,sizeh)
elif image in args: im = Image.open(args.image) 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()) pixels = list(im.getdata())
width, height = im.size width, height = im.size
@@ -57,7 +61,8 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
for w in widthlist: for w in widthlist:
if rnd: np.random.shuffle(heightlist) if rnd: np.random.shuffle(heightlist)
for h in 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) to_send = "px {} {} {}\n".format(w,h,color)
sock.sendall(bytes(to_send, "utf-8")) sock.sendall(bytes(to_send, "utf-8"))
sock.close() sock.close()