capdim

Caps an N-dimensional array to a maximum total volume (the product of its dimensions) while preserving proportions.