coffeebank / coffee-maubot

Matrix bot plugins for Maubot 🍢 Add link previews, choose, and other tools to your Matrix chat ☕
https://coffeebank.github.io/coffee-maubot
11 stars 5 forks source link

urlpreview: Improve showing images that are smaller than MAX_IMAGE_EMBED px #13

Closed coffeebank closed 1 year ago

coffeebank commented 1 year ago

Currently, all images are set to MAX_IMAGE_EMBED px wide, even if the image is much smaller.

We can detect the image's width/height and adjust it to show min(width or height, MAX_IMAGE_EMBED) for a better user experience.

This can be an optional external dependency: https://stackoverflow.com/questions/6444548/how-do-i-get-the-picture-size-with-pil