Hi @superpotato
There is a third party plugin that I came across recently that extends the functionality of the ACF gallery field and offers this functionality out of the box.
Please take a look at this page for more info on this: https://github.com/tmconnect/ACF-Justified-Image-Grid
I hope this info helps.