diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-06-30 16:46:29 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-07-01 16:55:27 +0100 |
commit | 47df99daf6371eb3d7cdbe1ac9170a7f88749dc1 (patch) | |
tree | 4b4600c40ffffaea4f471457901965ad2b269aa3 /t/app/controller/json.t | |
parent | e623594f10d74a8dfb5eaea801c43f4996b15a1e (diff) |
Fix photo orientation in modern browsers.
We use Dropzone (the photo upload library) to shrink photos client-side
before uploading in the background and display thumbnails. For the
resized upload, Dropzone restores the original Exif data, including
orientation, so it can be correctly oriented server-side; for a
thumbnail, it orients the image itself for immediate display.
Recently, browsers have started honouring Exif orientation much more
widely (Chrome 81+ and Firefox 77+ both now do it by default). This
means the data Dropzone gets from a resize has already been oriented
according to the Exif orientation data. Then Dropzone either looks at
the orientation to correct for display (thumbnail), or adds back the
Exif orientation data (upload) – in both cases, this leads to a double
implementation of the orientation, and an incorrect display.
To fix this, if we detect we are on a modern browser, we do not try and
fix orientation ourself [1], and in all cases we do not add any Exif
data back in (we only strip it server-side anyway). Conversely, that
means on a non-modern browser, we always perform a manual orientation
because no Exif data will be being sent server-side.
Also includes a fix to the orientation code [2] which wouldn't be
noticed in thumbnail generation as they are square, but could be now we
may be orienting full size photos.
[1] https://gitlab.com/meno/dropzone/-/merge_requests/80
[2] https://gitlab.com/meno/dropzone/-/merge_requests/45
Diffstat (limited to 't/app/controller/json.t')
0 files changed, 0 insertions, 0 deletions