random picture

This commit is contained in:
Jörn-Michael Miehe 2022-10-11 00:29:27 +00:00
parent 3c925726d3
commit 0c51199215

View file

@ -91,14 +91,21 @@ async def get_file(path: str) -> BytesIO:
return buffer
async def load_picture_standard() -> Image.Image:
async def load_picture_standard(
index: int,
) -> Image.Image:
"""
Bild laden und einen quadratischen Ausschnitt
aus der Mitte nehmen
"""
print(await list_images(""))
# Bild laden
img_buffer = await get_file("lena2.jpg")
rnd = random.Random(f"{loesungswort}{index}")
dat = rnd.choice(await list_images(""))
img_buffer = await get_file(dat)
img = Image.open(img_buffer)
# Größen bestimmen
@ -114,7 +121,7 @@ async def load_picture_standard() -> Image.Image:
))
img = img.resize(
size=(400, 400),
size=(500, 500),
resample=Image.ANTIALIAS,
)
@ -186,7 +193,7 @@ async def get_picture_for_day(
# Position des Buchstaben bestimmen
rnd = random.Random(f"{loesungswort}{index}")
xy = tuple(rnd.choices(range(30, 370), k=2))
xy = tuple(rnd.choices(range(30, 470), k=2))
# betroffenen Bildbereich bestimmen
text_box = await get_text_box(