mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
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:
@@ -16,6 +16,7 @@ package resources
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -264,6 +265,10 @@ func (r *resourceAdapter) Width() int {
|
||||
return r.getImageOps().Width()
|
||||
}
|
||||
|
||||
func (r *resourceAdapter) DecodeImage() (image.Image, error) {
|
||||
return r.getImageOps().DecodeImage()
|
||||
}
|
||||
|
||||
func (r *resourceAdapter) getImageOps() resource.ImageOps {
|
||||
img, ok := r.target.(resource.ImageOps)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user