I think there are two approaches we can take:
- Read the metadata, then try to output transform: ... attributes in CSS to compensate. So this image would get a transform: rotate(90) or something. It looks like we can flip stuff with scale(-1, 1).
- Read the metadata, then completely rebuild the image as a transformed version with no metadata.
(1) is easier, sort of, but might lead to an enormous pile of terrible bugs if every browser doesn't work pretty much the same way.
(2) will definitely work but requires changes to Files so we can keep track of the original image and its "display" rendering, and we'll have weird cases where right click into new tab + download image downloads a different file than left-click into lightbox, then right-click + save-as.
We run into this as well, mainly when uploading photos of flipover sheets and whiteboards (to Maniphest or Phriction). Our workaround for now is to ⌘ + click, so the image will render directly into the browser instead of using the lightbox.