Merge branch 'main' into feature/#311

This commit is contained in:
Ace
2024-06-25 17:55:15 +02:00
committed by GitHub
14 changed files with 195 additions and 163 deletions

View File

@@ -41,7 +41,10 @@ class Webshot(inkycal_module):
},
"crop_h": {
"label": "Please enter the crop height",
}
},
"rotation": {
"label": "Please enter the rotation. Must be either 0, 90, 180 or 270",
},
}
def __init__(self, config):
@@ -73,6 +76,12 @@ class Webshot(inkycal_module):
else:
self.crop_y = 0
self.rotation = 0
if "rotation" in config:
self.rotation = int(config["rotation"])
if self.rotation not in [0, 90, 180, 270]:
raise Exception("Rotation must be either 0, 90, 180 or 270")
# give an OK message
logger.debug(f'Inkycal webshot loaded')
@@ -106,7 +115,7 @@ class Webshot(inkycal_module):
logger.info(
f'preparing webshot from {self.url}... cropH{self.crop_h} cropW{self.crop_w} cropX{self.crop_x} cropY{self.crop_y}')
shot = WebShot()
shot = WebShot(size=(im_height, im_width))
shot.params = {
"--crop-x": self.crop_x,
@@ -152,11 +161,21 @@ class Webshot(inkycal_module):
centerPosX = int((im_width / 2) - (im.image.width / 2))
webshotSpaceBlack.paste(im_webshot_black, (centerPosX, webshotCenterPosY))
im_black.paste(webshotSpaceBlack)
webshotSpaceColour.paste(im_webshot_colour, (centerPosX, webshotCenterPosY))
im_colour.paste(webshotSpaceColour)
if self.rotation != 0:
webshotSpaceBlack.paste(im_webshot_black, (centerPosX, webshotCenterPosY))
im_black.paste(webshotSpaceBlack)
im_black = im_black.rotate(self.rotation, expand=True)
webshotSpaceColour.paste(im_webshot_colour, (centerPosX, webshotCenterPosY))
im_colour.paste(webshotSpaceColour)
im_colour = im_colour.rotate(self.rotation, expand=True)
else:
webshotSpaceBlack.paste(im_webshot_black, (centerPosX, webshotCenterPosY))
im_black.paste(webshotSpaceBlack)
webshotSpaceColour.paste(im_webshot_colour, (centerPosX, webshotCenterPosY))
im_colour.paste(webshotSpaceColour)
im.clear()
logger.info(f'added webshot image')