The issue is that JPEG allows rotation to be specified in the photo’s metadata, but not all viewing clients honor those flags. Mobile devices typically use the metadata so they don’t have to actually re-arrange the data from the camera sensor. I don’t recall if java’s ImageIO.read() will make the adjustment. You might want to experiment with it.
I have discovered that there is one landscape orientation where the image is correct. I will look into the Image.IO.read() to see if I can get this data. I am doing other things to crop and compress the image before storing it. So, doing a rotation or AffineTransform would not be an issue, if I can find the correct metadata that indicates rotation.