Opened 89 minutes ago
#37041 new Uncategorized
get_image_dimensions ignores exif roration
| Reported by: | Johannes Maron | Owned by: | |
|---|---|---|---|
| Component: | File uploads/storage | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Johannes Maron | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hi there!
While working on an unrelated update on django-pictures, I noticed that get_image_dimensions ignores the EXIF rotation of an image.
Now, is this intended or not? I could make an argument both ways. However, when you display an image in a browser (likely with Django) , browsers will rotate the image by default; see also: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/image-orientation
So, if those values are used anywhere, like in the width/height attribute on an img tag (like it's happening in django-pictures). They will be “wrong.”
Now, the question is, should get_image_dimensions return the pixel dimension or the visual dimension of the image?
My advice: Let's do both and provide an explicit option. When using the function or the width/height fields, let's allow users to provide an option. We can keep the default as is and avoid a breaking change. Maybe deprecate the default in favor of an explicit user choice.
Cheers!
Joe