--
Ticket URL: <https://code.djangoproject.com/ticket/34035>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "EXIF Rotation 0.jpg" added.
* Attachment "EXIF Rotation 1.jpg" added.
* Attachment "EXIF Rotation 2.jpg" added.
* Attachment "EXIF Rotation 3.jpg" added.
* Attachment "EXIF Rotation 4.jpg" added.
* Attachment "EXIF Rotation 5.jpg" added.
* Attachment "EXIF Rotation 6.jpg" added.
* Attachment "EXIF Rotation 7.jpg" added.
* Attachment "EXIF Rotation 8.jpg" added.
* status: new => closed
* resolution: => invalid
Comment:
Django simply uses [https://github.com/python-pillow/Pillow Pillow] to
retrieve the dimensions, so this should be reproduced without Django and
then (if a valid issue) reported there. A quick search revealed
[https://github.com/python-pillow/Pillow/issues/4537 a possibly related
issue].
If my analysis is incorrect, please reopen this ticket with an explanation
of where Django is at fault.
--
Ticket URL: <https://code.djangoproject.com/ticket/34035#comment:1>
* 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>
Comment (by David Sanders):
Adam I'd encourage you to start a discussion on the django-developers
mailing list [1] seeing as this is a behaviour change. Your suggestion
seems like it could be a helpful addition but many folks have probably
already encoded exif rotation into their codebases and might get an
unwelcome surprise if Django started doing it… there may be a bunch of
other reasons that folks would rather it not behave this way? 🤔
That being said the triage team might simply accept it :)
[1] https://groups.google.com/g/django-developers
--
Ticket URL: <https://code.djangoproject.com/ticket/34035#comment:3>
* status: new => closed
* type: Bug => Cleanup/optimization
* resolution: => wontfix
Comment:
I agree with David that some discussion is needed because this change is
backward incompatible. You can also subclass `ImageField` if the current
behavior doesn't suit you.
Please [https://docs.djangoproject.com/en/stable/internals/contributing
/triaging-tickets/#closing-tickets follow the triaging guidelines with
regards to wontfix tickets] and take this to DevelopersMailingList to
reach a wider audience and see what other think.
--
Ticket URL: <https://code.djangoproject.com/ticket/34035#comment:4>