Skip to content

Image distorted when rotating and cropping/filling using the smart anchor #11266

@eiszfuchs

Description

@eiszfuchs

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.112.3+extended linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

The bug is also present in

hugo v0.115.3-5c2e014a5150553a9fa4f9c1eb7dc4db89c0f1ab+extended linux/amd64 BuildDate=2023-07-13T16:11:34Z VendorInfo=gohugoio

Description

I am currently collecting a lot of JPEG files of different sources and try to present them with thumbnails. Since photos aren't rotated automatically, I wrote a few partials that help me identify resources and normalize rotation from .Exif. I soon noticed that portrait images were distorted in my thumbnail list.

This might be related to #6120, but I'm not sure.

Reproduction steps

Create a shortcode to resize images:

{{ $r := .Get "r" }}
{{ with $.Page.Resources.GetMatch (.Get "src") }}
    {{ with .Fill (printf "r%s 200x200 smart" $r) }}
        <img src={{ .RelPermalink }} width={{ .Width }} height={{ .Height }} >
    {{ end }}

    {{ with .Fit (printf "r%s 200x200 smart" $r) }}
        <img src={{ .RelPermalink }} width={{ .Width }} height={{ .Height }} >
    {{ end }}
{{ end }}

Use the shortcode in a post:

<!-- Using images from https://github.com/recurser/exif-orientation-examples to test -->

{{< fill-bug src="Portrait_0.jpg" r="0" >}}

{{< fill-bug src="Portrait_6.jpg" r="270" >}}

You'll get:

20230719-110454

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions