You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The next release (v0.121.2) includes an AutoOrient image filter that rotates and flips an image as needed per its EXIF orientation tag. For example, to auto-orient and then resize:
{{ $filters := slice
images.AutoOrient
(images.Process "resize 200x")
}}
{{ with resources.Get "images/original.jpg" }}
{{ with images.Filter $filters . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
If you build Hugo from source (HEAD), you can test all EXIF orientation values with:
git clone --single-branch -b hugo-github-issue-11717 https://github.com/jmooring/hugo-testing hugo-github-issue-11717
cd hugo-github-issue-11717
hugo server
Two questions come to mind...
1) Why is this necessary?
Because Go's JPEG decoder ignores the EXIF Orientation tag. An issue to correct this was opened in 2012, but is unlikely to be addressed due to concerns about backwards compatibility.
2) Why doesn't Hugo automatically handle this when decoding images?
I guess we might at some point, but similar to the above, the change would not be backwards compatible in some cases; some site and theme authors have already implemented handling for some of the orientation values (those that do not involve flipping/mirroring).
I don't think golang/go#4341 is really hung up on backwards compatibility. I think no one really wants the behavior where images get rotated wrong, and if you submitted a patch they would take it, and at worst throw an option into GODEBUG to turn it off.
Why doesn't Hugo automatically handle this when decoding images?
Performance is one argument, reading the EXIF info is not free. I have tens of thousand images processed by Hugo and I know that note one of them need to be "auto oriented" so why would I want to waste all the CPU?
Next Hugo (soon) will have a simple to use images.AutoOrient filter.
Activity
earthboundkid commentedon Dec 31, 2018
Awesome! Glad there is a simple solution. This will save me time.
124 remaining items
jmooring commentedon Dec 20, 2023
The next release (v0.121.2) includes an AutoOrient image filter that rotates and flips an image as needed per its EXIF orientation tag. For example, to auto-orient and then resize:
If you build Hugo from source (HEAD), you can test all EXIF orientation values with:
Two questions come to mind...
1) Why is this necessary?
Because Go's JPEG decoder ignores the EXIF Orientation tag. An issue to correct this was opened in 2012, but is unlikely to be addressed due to concerns about backwards compatibility.
2) Why doesn't Hugo automatically handle this when decoding images?
I guess we might at some point, but similar to the above, the change would not be backwards compatible in some cases; some site and theme authors have already implemented handling for some of the orientation values (those that do not involve flipping/mirroring).
earthboundkid commentedon Dec 21, 2023
I don't think golang/go#4341 is really hung up on backwards compatibility. I think no one really wants the behavior where images get rotated wrong, and if you submitted a patch they would take it, and at worst throw an option into GODEBUG to turn it off.
bep commentedon Dec 29, 2023
Performance is one argument, reading the EXIF info is not free. I have tens of thousand images processed by Hugo and I know that note one of them need to be "auto oriented" so why would I want to waste all the CPU?
Next Hugo (soon) will have a simple to use
images.AutoOrientfilter.bep commentedon Jan 31, 2024
We now have a filter that handles this.
github-actions commentedon Feb 22, 2024
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.