diff --git a/resources/images/images_golden_integration_test.go b/resources/images/images_golden_integration_test.go index 3245f125a75..dd2a6e06026 100644 --- a/resources/images/images_golden_integration_test.go +++ b/resources/images/images_golden_integration_test.go @@ -118,6 +118,55 @@ Home. {{ template "filters" (dict "name" "unsharpmask.jpg" "img" $sunset "filters" (images.UnsharpMask 10 0.4 0.03)) }} +{{ define "filters"}} +{{ if lt (len (path.Ext .name)) 4 }} + {{ errorf "No extension in %q" .name }} +{{ end }} +{{ $img := .img.Filter .filters }} +{{ $name := printf "images/%s" .name }} +{{ with $img | resources.Copy $name }} +{{ .Publish }} +{{ end }} +{{ end }} +` + + runGolden(t, name, files) +} + +func TestGoldenFiltersText(t *testing.T) { + t.Parallel() + + if skipGolden { + t.Skip("Skip golden test on this architecture") + } + + // Will be used to generate golden files. + name := "filters_text" + + files := ` +-- hugo.toml -- +-- assets/sunset.jpg -- +sourcefilename: ../testdata/sunset.jpg + +-- layouts/index.html -- +Home. +{{ $sunset := resources.Get "sunset.jpg" }} +{{ $textOpts := dict + "color" "#fbfaf5" + "linespacing" 8 + "size" 28 + "x" (div $sunset.Width 2 | int) + "alignx" "center" + "y" 190 +}} + +{{ $text := "Pariatur deserunt sunt nisi sunt tempor quis eu. Sint et nulla enim officia sunt cupidatat. Eu amet ipsum qui velit cillum cillum ad Lorem in non ad aute." }} +{{ template "filters" (dict "name" "text_alignx-center.jpg" "img" $sunset "filters" (images.Text $text $textOpts )) }} +{{ $textOpts = (dict "alignx" "right") | merge $textOpts }} +{{ template "filters" (dict "name" "text_alignx-right.jpg" "img" $sunset "filters" (images.Text $text $textOpts )) }} +{{ $textOpts = (dict "alignx" "left") | merge $textOpts }} +{{ template "filters" (dict "name" "text_alignx-left.jpg" "img" $sunset "filters" (images.Text $text $textOpts )) }} + {{ define "filters"}} {{ if lt (len (path.Ext .name)) 4 }} {{ errorf "No extension in %q" .name }} diff --git a/resources/images/testdata/images_golden/filters_text/text_alignx-center.jpg b/resources/images/testdata/images_golden/filters_text/text_alignx-center.jpg new file mode 100644 index 00000000000..090600f5f26 Binary files /dev/null and b/resources/images/testdata/images_golden/filters_text/text_alignx-center.jpg differ diff --git a/resources/images/testdata/images_golden/filters_text/text_alignx-left.jpg b/resources/images/testdata/images_golden/filters_text/text_alignx-left.jpg new file mode 100644 index 00000000000..d77e301df32 Binary files /dev/null and b/resources/images/testdata/images_golden/filters_text/text_alignx-left.jpg differ diff --git a/resources/images/testdata/images_golden/filters_text/text_alignx-right.jpg b/resources/images/testdata/images_golden/filters_text/text_alignx-right.jpg new file mode 100644 index 00000000000..3b727234a7e Binary files /dev/null and b/resources/images/testdata/images_golden/filters_text/text_alignx-right.jpg differ