Added a flag to flip the image horizontally