How can I create a masonry layout?

The Sec Image Boxes module has a 3 column and 4 column masonry layout option

Whether for a portfolio or image gallery, we recommend using the Resources template as a starting point to create your masonry layout because it includes a preconfigured section that you can easily modify in the settings.

If you already created a page, you can create a test page with the resources template and save the section with the masonry layout to add to your page.