Define best combination of width and height for gallery.