Skip to content

Instantly share code, notes, and snippets.

@vijinho
Last active August 29, 2015 14:08
Show Gist options
  • Save vijinho/ff3aca32ebdb6739811d to your computer and use it in GitHub Desktop.
Save vijinho/ff3aca32ebdb6739811d to your computer and use it in GitHub Desktop.
Determine image orientation from width and height
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