Last active
August 29, 2015 14:08
-
-
Save vijinho/ff3aca32ebdb6739811d to your computer and use it in GitHub Desktop.
Determine image orientation from width and height
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
def orientation(self, width, height): | |
""" | |
Determine an image orientation based on width and height | |
:param w: width | |
:param h: height | |
:return: boolean (landscape, portrait, square) | |
""" | |
square = False | |
landscape = False | |
portrait = False | |
if width < height: | |
portrait = True | |
elif width > height: | |
landscape = True | |
elif width == height: | |
square = True | |
return {'landscape' : landscape, 'portrait' : portrait ,'square' : square } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment