Automatic determination of aspect ratio