Skip to content

Add support for image AutoOrientationΒ #5181

Closed

Description

@bep

Activity

  1. added this to the v0.49 milestone on Sep 7, 2018
  2. modified the milestones: v0.49, v0.50 on Sep 24, 2018
  3. modified the milestones: v0.50, v0.51 on Oct 6, 2018
  4. modified the milestones: v0.51, v0.53 on Nov 8, 2018
  5. modified the milestones: v0.53, v0.54 on Dec 6, 2018
  6. earthboundkid commented on Dec 31, 2018

    @earthboundkid
    Contributor

    Awesome! Glad there is a simple solution. This will save me time.

  7. modified the milestones: v0.54, v0.55 on Feb 1, 2019
  8. modified the milestones: v0.55, v0.56 on Mar 7, 2019
  9. 124 remaining items

  10. added this to the v0.121.0 milestone on Oct 31, 2023
  11. modified the milestones: v0.121.0, v0.122.0 on Dec 6, 2023
  12. jmooring commented on Dec 20, 2023

    @jmooring
    Member

    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).

  13. earthboundkid commented on Dec 21, 2023

    @earthboundkid
    Contributor

    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.

  14. bep commented on Dec 29, 2023

    @bep
    MemberAuthor
    1. 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.

  15. modified the milestones: v0.122.0, v0.123.0, v0.124.0 on Jan 27, 2024
  16. bep commented on Jan 31, 2024

    @bep
    MemberAuthor

    We now have a filter that handles this.

  17. github-actions commented on Feb 22, 2024

    @github-actions

    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.

  18. locked as resolved and limited conversation to collaborators on Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions