Created
June 1, 2016 15:44
-
-
Save nitheeshas/5855b4358c18161c2e5e70dd45956f44 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
from PIL import Image, ExifTags | |
import sys | |
''' | |
1 2 3 4 5 6 7 8 | |
888888 888888 88 88 8888888888 88 88 8888888888 | |
88 88 88 88 88 88 88 88 88 88 88 88 | |
8888 8888 8888 8888 88 8888888888 8888888888 88 | |
88 88 88 88 | |
88 88 888888 888888 | |
''' | |
def getOrientation(tag): | |
switcher = { | |
3: 180, | |
6: 270, | |
8: 90 | |
} | |
return switcher.get(tag, "Undefined") | |
if __name__ == "__main__": | |
try: | |
image=Image.open(sys.argv[1]) | |
except: | |
print "Cannot load image" | |
exit() | |
for tag in ExifTags.TAGS.keys(): | |
if ExifTags.TAGS[tag]=='Orientation': | |
break | |
exif=dict(image._getexif().items()) | |
print getOrientation(exif[tag]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment