Merge pull request #2 from guilledk/fix_rectangular_imgs

Fix bug where we only supported square imgs on telegram frontend reply
pull/3/head
Guillermo Rodriguez 2023-01-07 09:06:02 -03:00 committed by GitHub
commit 83465aadaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -113,10 +113,10 @@ async def run_skynet_telegram(
logging.info(result['id']) logging.info(result['id'])
img_raw = zlib.decompress(bytes.fromhex(result['img'])) img_raw = zlib.decompress(bytes.fromhex(result['img']))
logging.info(f'got image of size: {len(img_raw)}') logging.info(f'got image of size: {len(img_raw)}')
size = (512, 512)
meta = result['meta']['meta'] meta = result['meta']['meta']
size = (int(meta['width']), int(meta['height']))
if meta['upscaler'] == 'x4': if meta['upscaler'] == 'x4':
size = (2048, 2048) size = (size[0] * 4, size[1] * 4)
img = Image.frombytes('RGB', size, img_raw) img = Image.frombytes('RGB', size, img_raw)
@ -147,10 +147,10 @@ async def run_skynet_telegram(
logging.info(result['id']) logging.info(result['id'])
img_raw = zlib.decompress(bytes.fromhex(result['img'])) img_raw = zlib.decompress(bytes.fromhex(result['img']))
logging.info(f'got image of size: {len(img_raw)}') logging.info(f'got image of size: {len(img_raw)}')
size = (512, 512)
meta = result['meta']['meta'] meta = result['meta']['meta']
size = (int(meta['width']), int(meta['height']))
if meta['upscaler'] == 'x4': if meta['upscaler'] == 'x4':
size = (2048, 2048) size = (size[0] * 4, size[1] * 4)
img = Image.frombytes('RGB', size, img_raw) img = Image.frombytes('RGB', size, img_raw)
@ -176,7 +176,7 @@ async def run_skynet_telegram(
'config', {'attr': attr, 'val': val}) 'config', {'attr': attr, 'val': val})
except BaseException as e: except BaseException as e:
reply_text = str(e.value) reply_txt = str(e)
finally: finally:
await bot.reply_to(message, reply_txt) await bot.reply_to(message, reply_txt)