Rearchitecture the project for Poetry support.

This commit is contained in:
Kat Inskip 2023-10-06 16:07:16 -07:00
parent 6cc517c163
commit 4ae3ddc2c0
16 changed files with 603 additions and 47 deletions

17
konawall/imager.py Normal file
View file

@ -0,0 +1,17 @@
import tempfile
import logging
from PIL import Image
def combine_to_viewport(displays: list, files: list):
# Create an image that is the size of the combined viewport, with offsets for each display
max_width = max([display.x + display.width for display in displays])
max_height = max([display.y + display.height for display in displays])
combined = Image.new("RGB", (max_width, max_height))
for i, file in enumerate(files):
open_image = Image.open(file, "r")
resized_image = open_image.resize((displays[i].width, displays[i].height))
combined.paste(resized_image, (displays[i].x, displays[i].y))
file = tempfile.NamedTemporaryFile(delete=False)
logging.debug(f"Created temporary file {file.name} to save combined viewport image into")
combined.save(file.name, format="PNG")
return file