Why does my photo open sideways?
Phones often store a photo sideways and add a tag saying which way is up. Image Viewer by Zaweba reads that tag, and R turns and saves any that are still wrong.

Your photo opens sideways because the camera saved it on its side and wrote a small note, the EXIF orientation tag, saying which way is up. Programs that ignore the tag show the raw sideways picture. Image Viewer by Zaweba reads the tag and shows photos upright, and for the few that are still wrong, pressing R turns the picture and offers to save it.
It is one of the most common puzzles with phone photos. The picture looks fine on the phone, fine in one program, and sideways in another. Nothing is broken; the programs just disagree about whether to read that note.
What the orientation tag is
When you hold a phone or camera upright to take a portrait shot, the sensor still records the picture the same way it always does. Rather than turning the pixels round, which takes time, the camera stores them as they came and adds a tag to the file that says, in effect, turn this a quarter right before showing it.
Anything that honours the tag shows the photo correctly. Anything that ignores it shows the stored pixels, which are on their side. That is why the same file can look right in one place and wrong in another, and why emailing or uploading a photo sometimes makes it flip.
How Image Viewer handles it
Image Viewer honours the EXIF orientation tag, so photos are shown the right way up as soon as they open. You don't have to do anything for that to happen.
Some pictures still arrive sideways. A scan placed the wrong way on the glass, a screenshot from a turned tablet, or a photo whose tag was stripped by another program all lack a correct tag, so there is nothing to read. Those need turning by hand.
Turning a photo and keeping it turned
Press R to rotate right, or Shift+R or L to rotate left. When you step away from the picture, Image Viewer asks once: Save the rotation? Say yes and the file is changed, so it will look right everywhere, not just in Image Viewer.
How the save is done depends on the file. JPEGs whose size is a whole number of compression blocks are turned losslessly, without any loss of quality. Other JPEGs are re-encoded at quality 95. PNG, BMP, TIFF and still GIFs are re-encoded losslessly. EXIF details such as the camera and date are kept either way.
If you turn photos often, Settings lets you choose how saving works: Ask, Always or Never. Always suits someone tidying a big folder of scans; Never suits someone who only wants to turn pictures for a quick look without changing the files.
Fixing a whole folder
Open the first photo in the folder and step through with the Right arrow or Space. Most will already be upright. When one isn't, press R or L until it looks right and carry on. With the setting on Ask, you confirm each save as you leave the picture; with Always, it just happens.
The bottom bar shows the position, such as 12 of 87, so you know how far you have to go.
The same fix elsewhere in the app
The orientation tag also matters when you set a picture as your desktop background. Windows can be fussy about it, so Image Viewer sends any picture turned by EXIF through an upright JPEG copy kept in its settings folder, and the wallpaper comes out the right way up.
On the Mac and Linux version, rotation is saved through the EXIF orientation too, which keeps the original pixels untouched.
In short
A sideways photo is usually a correct photo with an instruction some program ignored. Image Viewer follows the instruction, and when there isn't one, R and a quick yes put it right for good.