Calculate proportions for resizing images or other elements