florence-social / mastodon-fork

Florence's fork of Mastodon
GNU Affero General Public License v3.0
138 stars 15 forks source link

Image letterboxing #6

Open clarfonthey opened 5 years ago

clarfonthey commented 5 years ago

This is a glitch.social feature that we can incorporate. Documentation: https://glitch-soc.github.io/docs/features/media/

I'm a bit iffy on the implementation so I'm going to mark this as abstract.

ghost commented 5 years ago

The simplest way to do this is with CSS. You set a fixed size for the image, then set a background colour and the "object-fit" attribute to "contain". This fills the bounds, but retains the aspect ratio (giving you your "letterboxing" or "pillarboxing" effect).

The other way is to change the images themselves with a Ruby Gem that's a wrapper for ImageMagick. However that's computationally expensive and you'd need somewhere to cache the images to mitigate that.