Sid Gifari File Manager
🏠 Root
/
home
/
genremedia08
/
musicjukebox.overlookedtracks.com
/
common
/
resources
/
client
/
ui
/
interactions
/
utils
/
Editing: calc-new-size-from-aspect-ratio.ts
export function calcNewSizeFromAspectRatio( aspectRatio: number | null, oldWidth: number, oldHeight: number ) { let newWidth = oldWidth; let newHeight = oldHeight; if (aspectRatio) { if (oldHeight * aspectRatio > oldWidth) { newHeight = oldWidth / aspectRatio; } else { newWidth = oldHeight * aspectRatio; } } return {width: Math.floor(newWidth), height: Math.floor(newHeight)}; } export function aspectRatioFromStr(ratio: string | null): number | null { if (!ratio) return null; const parts = ratio.split(':'); return parseInt(parts[0]) / parseInt(parts[1]); }
Save
Cancel