#34035: ImageField doesn't consider EXIF rotation when storing width and height
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam):
* status: closed => new
* resolution: invalid =>
Comment:
Here is [https://github.com/python-
pillow/Pillow/issues/4703#issuecomment-645219973 another Pillow issue]
that may be of interest. It seems that Pillow ignoring the EXIF
orientation is by design. Pillow is used in various contexts, not just
web. I think in other cases it may make sense to return the dimensions
without considering the EXIF orientation. But the web defaults to
considering the EXIF orientation (see
[https://chromestatus.com/feature/6313474512650240 this link]). Since
Django is for the web, I think it should consider the EXIF orientation. I
was able to make a quick and dirty fix to django/core/files/images.py. I
added the following right above where it says `return p.image.size`
([https://github.com/django/django/blob/3.2.15/django/core/files/images.py#L77
source]):
{{{
try:
exif = p.image._getexif()
except (AttributeError, ValueError):
pass
else:
if exif is not None and exif[274] > 4:
return (p.image.size[1], p.image.size[0])
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34035#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701836d747479-9db721fc-7873-415e-b1cc-5e946036cb6f-000000%40eu-central-1.amazonses.com.