Created
December 13, 2013 21:39
-
-
Save csinchok/7951812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function computeAspectRatio(_w, _h) { | |
if (_w !== 0 && _h !== 0) { | |
var aspectRatio = Math.ceil(_w/_h * 10); | |
//smooth out rounding issues. | |
switch (aspectRatio) { | |
case 30: | |
case 31: | |
crop = "3x1"; | |
break; | |
case 20: | |
crop = "2x1"; | |
break; | |
case 14: | |
crop = "4x3"; | |
break; | |
case 18: | |
crop = "16x9"; | |
break; | |
case 8: | |
crop = "3x4"; | |
break; | |
case 10: | |
crop = "1x1"; | |
break; | |
default: | |
crop = "original"; | |
} | |
return crop; | |
} | |
else { | |
return "16x9" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment