code: def rotate(self, img):
          
          try:
              exif = image2exif.get_exif(img)
          except AttributeError:
              # image format doesn't support exif
              return img
          
          orientation = exif.get('Orientation', 1)
  
          landscape = img.height < img.width
          
          if orientation == 6 and landscape:
              print("ROTATING")
              return img.rotate(-90)
  
          return img
docs: Rotate image if exif says it needs it