How to show gallery of images with different width/height proportions?

Hello,
with custom html/css template(no bootstrap or tailwindcss or other css library is used)
I need to show gallery of images with different width/height proportions, like : Screenshot by Lightshot
I mean different images has different size and I need to align them in some way.
I suppose that I need to set height some way and width automatically.
Are there some decision/libraries for that ?
Thanks!