def reorient(image, orientation):
 o = TIFF_ORIENTATIONS.get(orientation, orientation)
 if (o == 'top_left'):
  return image
 elif (o == 'top_right'):
  return image[..., ::(-1), :]
 elif (o == 'bottom_left'):
  return image[..., ::(-1), :, :]
 elif (o == 'bottom_right'):
  return image[..., ::(-1), ::(-1), :]
 elif (o == 'left_top'):
  return numpy.swapaxes(image, (-3), (-2))
 elif (o == 'right_top'):
  return numpy.swapaxes(image, (-3), (-2))[..., ::(-1), :]
 elif (o == 'left_bottom'):
  return numpy.swapaxes(image, (-3), (-2))[..., ::(-1), :, :]
 elif (o == 'right_bottom'):
  return numpy.swapaxes(image, (-3), (-2))[..., ::(-1), ::(-1), :]

def reorient ( image , orientation ) : o = TIFF_ORIENTATIONS . get ( orientation , orientation ) if ( o == 'top_left' ) : return image elif ( o == 'top_right' ) : return image [ ... , : : ( - 1 ) , : ] elif ( o == 'bottom_left' ) : return image [ ... , : : ( - 1 ) , : , : ] elif ( o == 'bottom_right' ) : return image [ ... , : : ( - 1 ) , : : ( - 1 ) , : ] elif ( o == 'left_top' ) : return numpy . swapaxes ( image , ( - 3 ) , ( - 2 ) ) elif ( o == 'right_top' ) : return numpy . swapaxes ( image , ( - 3 ) , ( - 2 ) ) [ ... , : : ( - 1 ) , : ] elif ( o == 'left_bottom' ) : return numpy . swapaxes ( image , ( - 3 ) , ( - 2 ) ) [ ... , : : ( - 1 ) , : , : ] elif ( o == 'right_bottom' ) : return numpy . swapaxes ( image , ( - 3 ) , ( - 2 ) ) [ ... , : : ( - 1 ) , : : ( - 1 ) , : ]
return reoriented view of image array .