You might find
http://www.gmayor.com/photo_gallery_template.html useful. The table here fits the width between the margins so the column width will be determined by the (selected) number of columns that will fit between the current margins. Images will adapt to the width of the cells and the height is determined by the aspect ratio of the the imported image.