Image gallery that doesn't falls apart

This is an example for the article on how to create an image gallery that doesn't fall apart when different image sizes are uploaded. It doesn't distort the images, instead of that – the gallery "crops" the images to fit on the screen.

The original image with the area that is cropped which is grayed out.

Sample image