Skip to content

Unexpected image size with smart cropping #13688

Open
@jmooring

Description

@jmooring

See https://discourse.gohugo.io/t/missing-pixels-on-resize-crop/54584.

resources/images/images_integration_test.go

func TestIssue13688(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
-- layouts/home.html --
{{ with resources.Get "sunset.jpg" }}
  Original: {{ .Width }}x{{ .Height }}|
  {{- with .Crop "900x561 TopLeft" -}}
    CropTopLeft: {{ .Width }}x{{ .Height }}|
  {{- end }}
  {{- with .Crop "900x561 Smart" -}}
    CropSmart: {{ .Width }}x{{ .Height }}|
  {{ end }}
{{ end }}
-- assets/sunset.jpg --
sourcefilename: ../testdata/sunset.jpg
`

	b := hugolib.Test(t, files)

	b.AssertFileContent("public/index.html",
		"Original: 900x562|CropTopLeft: 900x561|CropSmart: 900x561|",
	)
}

In the above, the actual file content is:

Original: 900x562|CropTopLeft: 900x561|CropSmart: 899x560|

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions