ESN-Trondheim / ESNbot

A Slack bot for ESN Trondheim
MIT License
3 stars 1 forks source link

Coverphoto fails if picture is non-low #76

Closed LaiAlexander closed 10 months ago

LaiAlexander commented 10 months ago

This happened after PR #59, specifically commit e5c18f4

2023-11-08 20:12:44,073 - Stack trace - ERROR - cannot unpack non-iterable Image object
2023-11-08 20:12:44,074 - Stack trace - ERROR - Traceback (most recent call last):
  File "D:\Lai Alexander\Programming\Python\ESNbot\esnbot\main.py", line 138, in handle_command
    self.choose_command(command, arguments, channel, user, output)
  File "D:\Lai Alexander\Programming\Python\ESNbot\esnbot\main.py", line 166, in choose_command
    return func(self, channel, user, arguments, output)
  File "D:\Lai Alexander\Programming\Python\ESNbot\esnbot\commands.py", line 356, in coverphoto
    bg_low_res = cp.create_coverphoto(background_img, filename, argument)
  File "D:\Lai Alexander\Programming\Python\ESNbot\esnbot\graphics\coverphoto.py", line 150, in create_coverphoto
    background, bg_low_res = resize_background(background, dimensions)
TypeError: cannot unpack non-iterable Image object

Seems to happen when images are of okay resolution, i.e. bg_low_res == False

LaiAlexander commented 10 months ago

This is the culprit: https://github.com/ESN-Trondheim/ESNbot/blob/5a319928185c8f07e637f40002fb66bc1e7a61f8/esnbot/graphics/coverphoto.py#L175-L176

Only happens if the supplied background has the exact same dimensions as the overlay, must also return the bool. (On a side note, this error would have been caught if we would have used type hinting/type checking)