images: Add images.Overlay filter

This allows for constructs ala:

```
{{ $overlay := $img.Filter (images.Overlay $logo 50 50 )}}
```
Or:

```
{{ $logoFilter := (images.Overlay $logo 50 50 ) }}
{{ $overlay := $img | images.Filter $logoFilter }}
```

Which will overlay the logo in the top left corner (x=50, y=50) of `$img`.

Fixes #8057
Fixes #4595
Updates #6731
This commit is contained in:
Bjørn Erik Pedersen
2020-12-16 13:52:47 +01:00
parent a2d146ec32
commit 3ba147e702
12 changed files with 101 additions and 2 deletions

View File

@@ -533,6 +533,11 @@ func TestImageOperationsGolden(t *testing.T) {
fmt.Println(workDir)
}
gopher := fetchImageForSpec(spec, c, "gopher-hero8.png")
var err error
gopher, err = gopher.Resize("30x")
c.Assert(err, qt.IsNil)
// Test PNGs with alpha channel.
for _, img := range []string{"gopher-hero8.png", "gradient-circle.png"} {
orig := fetchImageForSpec(spec, c, img)
@@ -589,6 +594,7 @@ func TestImageOperationsGolden(t *testing.T) {
f.Invert(),
f.Hue(22),
f.Contrast(32.5),
f.Overlay(gopher.(images.ImageSource), 20, 30),
}
resized, err := orig.Fill("400x200 center")