Created
November 8, 2015 08:42
-
-
Save cfra/a78150000d2fa9431818 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 | |
img = Image.open(image_path) | |
if orientation == 2: | |
img = img.transpose(Image.FLIP_LEFT_RIGHT) | |
elif orientation == 3: | |
img = img.transpose(Image.ROTATE_180) | |
elif orientation == 4: | |
img = img.transpose(Image.FLIP_TOP_BOTTOM) | |
elif orientation == 5: | |
img = img.transpose(Image.ROTATE_270) | |
img = img.transpose(Image.FLIP_LEFT_RIGHT) | |
elif orientation == 6: | |
img = img.transpose(Image.ROTATE_270) | |
elif orientation == 7: | |
img = img.transpose(Image.ROTATE_90) | |
img = img.transpose(Image.FLIP_LEFT_RIGHT) | |
elif orientation == 8: | |
img = img.transpose(Image.ROTATE_90) | |
img.save(self.image.path, "JPEG", quality=95, optimize=True, progressive=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment