Added image reorientation to  main function