export function applyAspectRatio( width: number, height: number, aspectRatio: number ): { width: number; height: number } { const targetHeightFromWidth = width / aspectRatio; const targetWidthFromHeight = height * aspectRatio; if (targetHeightFromWidth <= height) { return { width: width, height: targetHeightFromWidth, }; } else { return { width: targetWidthFromHeight, height: height, }; } }