Exchangeable image file format (EXIF) is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras (including smartphones), and other devices. One of the tags in EXIF is Orientation tag, which specifies the orientation of the image, based on camera position during creating a photo.
CelesteCS Image Lossless Rotator plugin reads Orientation tag from JPEG files and rotates image accordingly if needed.
Orientation tag can potentially be available for both the JPEGS, supporting lossless rotation and not.