'Returns the image orientation of the buffer image or None
if it is undefined. Gets the original value from the Exif tag.
If the buffer has been rotated, then the value is adjusted to 1.
:return: Orientation value (1 - 8)
:rtype: int or None'

def get_orientation(self):

    segment = self._get_exif_segment()
    if segment:
        orientation = segment.primary['Orientation']
        if orientation:
            return orientation[0]
    return None
