thumbor: Avif and autorotation not working properly
When using avif, thumbor does not respect rotation of the photo according to the exif. If I use jpg or webp, the photo will rotate correctly
Sample photo: https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_4.jpg
thumbor==7.4.7
thumbor-aws==0.6.0
pillow-avif-plugin==1.3.1
https://github.com/OndrejIT/thumbor-crypto/archive/devel.tar.gz
pycurl==7.45.2
CairoSVG==2.6.0
sentry-sdk==1.17.0
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 23 (12 by maintainers)
I seem to be unable to reproduce the issue myself, but I was at one point. I think this may be the result of changes to how browsers handle EXIF transformations for AVIF images. As recently as December 15, 2021, a bug report for Chrome that exif transforms aren’t applied to AVIF images was closed as WONTFIX, citing the image format specifications. I don’t have the contents of that spec, but MIAF 7.3.10 gets quoted in these discussions; reproducing the excerpt:
These transformations are instead meant to come from the imir and irot transform flags of the image.
At some point since then, the Chromium developers must have had a change of heart, because it appears that EXIF transformations do in fact work for AVIF images in the latest Chrome, even in the absence of transform flags. I cannot find anything in the changelogs or issues to say when this occurred, which would tell me how that fits into the timeline of this issue being opened.
My understanding of the issue (based on my earlier reproduction) is that the reporter was viewing images in an application or browser that exclusively supported imir and irot. Or they were using a version of Safari that supports neither (I know that it was unsupported as late as Safari 17.3). The issue for the former situation is fixed in pillow-avif-plugin 1.4.2. There isn’t a solution to the latter issue aside from requiring newer Safari or enabling RESPECT_ORIENTATION.
On the basis of all that, I think it’s fair to say that this issue can be closed.
Sorry for the delay in responding here. It looks like this is a bug in pillow-avif-plugin itself. The AVIF image spec dictates that orientation info in exif metadata should be ignored, and so when converting from another image format with exif orientation it’s necessary to set the
irottransform flag on the image.I’ll look into fixing this in pillow-avif-plugin. In the meantime, it looks like this can be worked around by enabling the
RESPECT_ORIENTATIONsetting in thumbor.