Created
April 11, 2017 21:53
-
-
Save lucymtc/4d04b2507c6614f79b8c1c82057c0b8c to your computer and use it in GitHub Desktop.
Get resized width and height of an image maintaining its aspect ratio
This file contains hidden or 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
| var originalWidth = 2205; | |
| var originalHeight = 3500; | |
| var maxSize = 160; | |
| /** Thumbnails max width and height. */ | |
| var ratio = Math.min( maxSize / originalWidth, maxSize / originalHeight ); | |
| var thumbWidth = originalWidth * ratio; | |
| var thumbHeight = originalHeight * ratio; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment