| 1 |
--- |
| 2 |
title: images.Overlay |
| 3 |
description: Returns an image filter that overlays the source image at the given coordinates, relative to the upper left corner. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [] |
| 9 |
returnType: images.filter |
| 10 |
signatures: [images.Overlay RESOURCE X Y] |
| 11 |
--- |
| 12 |
|
| 13 |
## Usage |
| 14 |
|
| 15 |
Capture the overlay image as a resource: |
| 16 |
|
| 17 |
```go-html-template |
| 18 |
{{ $overlay := "" }} |
| 19 |
{{ $path := "images/logo.png" }} |
| 20 |
{{ with resources.Get $path }} |
| 21 |
{{ $overlay = . }} |
| 22 |
{{ else }} |
| 23 |
{{ errorf "Unable to get resource %q" $path }} |
| 24 |
{{ end }} |
| 25 |
``` |
| 26 |
|
| 27 |
The overlay image can be a [global resource](g), a [page resource](g), or a [remote resource](g). |
| 28 |
|
| 29 |
Create the filter: |
| 30 |
|
| 31 |
```go-html-template |
| 32 |
{{ $filter := images.Overlay $overlay 20 20 }} |
| 33 |
``` |
| 34 |
|
| 35 |
{{% include "/_common/functions/images/apply-image-filter.md" %}} |
| 36 |
|
| 37 |
## Example |
| 38 |
|
| 39 |
{{< img |
| 40 |
src="images/examples/zion-national-park.jpg" |
| 41 |
alt="Zion National Park" |
| 42 |
filter="Overlay" |
| 43 |
filterArgs="images/logos/logo-64x64.png,20,20" |
| 44 |
example=true |
| 45 |
>}} |