diff --git a/app/javascript/gabsocial/utils/media_aspect_ratio.js b/app/javascript/gabsocial/utils/media_aspect_ratio.js new file mode 100644 index 00000000..0a7d740a --- /dev/null +++ b/app/javascript/gabsocial/utils/media_aspect_ratio.js @@ -0,0 +1,17 @@ +export const minimumAspectRatio = .8; +export const maximumAspectRatio = 2.8; + +export const isPanoramic = ar => { + if (isNaN(ar)) return false; + return ar >= maximumAspectRatio; +} + +export const isPortrait = ar => { + if (isNaN(ar)) return false; + return ar <= minimumAspectRatio; +} + +export const isNonConformingRatio = ar => { + if (isNaN(ar)) return false; + return !isPanoramic(ar) && !isPortrait(ar); +}