What do you mean when you say gaps are created between them?
Do you mean you have the same acreage defined for each image such
that there are wider spaces between images when portrait layouts
get planted in the mix? If so, you should be able to plant them and
designate their spacing dynamically instead of using a fixed
allocation of space.