mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,14 +3,11 @@ title: images.AutoOrient
|
||||
description: Returns an image filter that rotates and flips an image as needed per its EXIF orientation tag.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.AutoOrient]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.AutoOrient]
|
||||
---
|
||||
|
||||
{{< new-in 0.121.2 />}}
|
||||
@@ -23,11 +20,10 @@ Create the filter:
|
||||
{{ $filter := images.AutoOrient }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
{{% note %}}
|
||||
When using with other filters, specify `images.AutoOrient` first.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> When using with other filters, specify `images.AutoOrient` first.
|
||||
|
||||
```go-html-template
|
||||
{{ $filters := slice
|
||||
|
@@ -3,14 +3,11 @@ title: images.Brightness
|
||||
description: Returns an image filter that changes the brightness of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Brightness PERCENTAGE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Brightness PERCENTAGE]
|
||||
---
|
||||
|
||||
The percentage must be in the range [-100, 100] where 0 has no effect. A value of `-100` produces a solid black image, and a value of `100` produces a solid white image.
|
||||
@@ -23,7 +20,7 @@ Create the image filter:
|
||||
{{ $filter := images.Brightness 12 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.ColorBalance
|
||||
description: Returns an image filter that changes the color balance of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.ColorBalance PCTRED PCTGREEN PCTBLUE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.ColorBalance PCTRED PCTGREEN PCTBLUE]
|
||||
---
|
||||
|
||||
The percentage for each channel (red, green, blue) must be in the range [-100, 500].
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.ColorBalance -10 10 50 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Colorize
|
||||
description: Returns an image filter that produces a colorized version of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Colorize HUE SATURATION PERCENTAGE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Colorize HUE SATURATION PERCENTAGE]
|
||||
---
|
||||
|
||||
The hue is the angle on the color wheel, typically in the range [0, 360].
|
||||
@@ -27,7 +24,7 @@ Create the filter:
|
||||
{{ $filter := images.Colorize 180 50 20 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,18 +3,16 @@ title: images.Config
|
||||
description: Returns an image.Config structure from the image at the specified path, relative to the working directory.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related: []
|
||||
returnType: image.Config
|
||||
signatures: [images.Config PATH]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: image.Config
|
||||
signatures: [images.Config PATH]
|
||||
aliases: [/functions/imageconfig]
|
||||
---
|
||||
|
||||
See [image processing] for an overview of Hugo's image pipeline.
|
||||
|
||||
[image processing]: /content-management/image-processing/
|
||||
|
||||
```go-html-template
|
||||
{{ $ic := images.Config "/static/images/a.jpg" }}
|
||||
|
||||
@@ -24,10 +22,9 @@ See [image processing] for an overview of Hugo's image pipeline.
|
||||
|
||||
Supported image formats include GIF, JPEG, PNG, TIFF, and WebP.
|
||||
|
||||
{{% note %}}
|
||||
This is a legacy function, superseded by the [`Width`] and [`Height`] methods for [global resources](g), [page resources](g), and [remote resources](g). See the [image processing] section for details.
|
||||
> [!note]
|
||||
> This is a legacy function, superseded by the [`Width`] and [`Height`] methods for [global resources](g), [page resources](g), and [remote resources](g). See the [image processing] section for details.
|
||||
|
||||
[`Width`]: /methods/resource/width/
|
||||
[`Height`]: /methods/resource/height/
|
||||
[`Width`]: /methods/resource/width/
|
||||
[image processing]: /content-management/image-processing/
|
||||
{{% /note %}}
|
||||
|
@@ -3,14 +3,11 @@ title: images.Contrast
|
||||
description: Returns an image filter that changes the contrast of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Contrast PERCENTAGE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Contrast PERCENTAGE]
|
||||
---
|
||||
|
||||
The percentage must be in the range [-100, 100] where 0 has no effect. A value of `-100` produces a solid grey image, and a value of `100` produces an over-contrasted image.
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.Contrast -20 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,16 +3,11 @@ title: images.Dither
|
||||
description: Returns an image filter that dithers an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- functions/images/Process
|
||||
- methods/resource/Colors
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: ['images.Dither [OPTIONS]']
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: ['images.Dither [OPTIONS]']
|
||||
---
|
||||
|
||||
{{< new-in 0.123.0 />}}
|
||||
@@ -28,7 +23,7 @@ method
|
||||
: (`string`) The dithering method. See the [dithering methods](#dithering-methods) section below for a list of the available methods. Default is `FloydSteinberg`.
|
||||
|
||||
serpentine
|
||||
: (`bool`) Applicable to error diffusion dithering methods, serpentine controls whether the error diffusion matrix is applied in a serpentine manner, meaning that it goes right-to-left every other line. This greatly reduces line-type artifacts. Default is `true`.
|
||||
: (`bool`) Applicable to error diffusion dithering methods, whether to apply the error diffusion matrix in a serpentine manner, meaning that it goes right-to-left every other line. This greatly reduces line-type artifacts. Default is `true`.
|
||||
|
||||
strength
|
||||
: (`float`) The strength at which to apply the dithering matrix, typically a value in the range [0, 1]. A value of `1.0` applies the dithering matrix at 100% strength (no modification of the dither matrix). The `strength` is inversely proportional to contrast; reducing the strength increases the contrast. Setting `strength` to a value such as `0.8` can be useful to reduce noise in the dithered image. Default is `1.0`.
|
||||
@@ -57,13 +52,13 @@ Or create the filter using the default settings:
|
||||
{{ $filter := images.Dither }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Dithering methods
|
||||
|
||||
See the [Go documentation] for descriptions of each of the dithering methods below.
|
||||
|
||||
[Go documentation]: https://pkg.go.dev/github.com/makeworld-the-better-one/dither/v2#pkg-variables
|
||||
[Go documentation]: https://pkg.go.dev/github.com/makeworld-the-better-one/dither/v2#pkg-variables
|
||||
|
||||
Error diffusion dithering methods:
|
||||
|
||||
|
@@ -3,13 +3,11 @@ title: images.Filter
|
||||
description: Applies one or more image filters to the given image resource.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- methods/resource/Filter
|
||||
returnType: images.ImageResource
|
||||
signatures: [images.Filter FILTERS... IMAGE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.ImageResource
|
||||
signatures: [images.Filter FILTERS... IMAGE]
|
||||
---
|
||||
|
||||
Apply one or more [image filters](#image-filters) to the given image.
|
||||
@@ -64,4 +62,4 @@ You can also apply image filters using the [`Filter`] method on a `Resource` obj
|
||||
|
||||
Use any of these filters with the `images.Filter` function, or with the `Filter` method on a `Resource` object.
|
||||
|
||||
{{< list-pages-in-section path=/functions/images filter=functions_images_no_filters filterType=exclude >}}
|
||||
{{% list-pages-in-section path=/functions/images filter=functions_images_no_filters filterType=exclude %}}
|
||||
|
@@ -3,14 +3,11 @@ title: images.Gamma
|
||||
description: Returns an image filter that performs gamma correction on an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Gamma GAMMA]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Gamma GAMMA]
|
||||
---
|
||||
|
||||
The gamma value must be positive. A value greater than 1 lightens the image, while a value less than 1 darkens the image. The filter has no effect when the gamma value is 1.
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.Gamma 1.667 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.GaussianBlur
|
||||
description: Returns an image filter that applies a gaussian blur to an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.GaussianBlur SIGMA]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.GaussianBlur SIGMA]
|
||||
---
|
||||
|
||||
The sigma value must be positive, and indicates how much the image will be blurred. The blur-affected radius is approximately 3 times the sigma value.
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.GaussianBlur 5 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Grayscale
|
||||
description: Returns an image filter that produces a grayscale version of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Grayscale]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Grayscale]
|
||||
---
|
||||
|
||||
## Usage
|
||||
@@ -21,7 +18,7 @@ Create the filter:
|
||||
{{ $filter := images.Grayscale }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Hue
|
||||
description: Returns an image filter that rotates the hue of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Hue SHIFT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Hue SHIFT]
|
||||
---
|
||||
|
||||
The hue angle shift is typically in the range [-180, 180] where 0 has no effect.
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.Hue -15 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Invert
|
||||
description: Returns an image filter that negates the colors of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Invert]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Invert]
|
||||
---
|
||||
|
||||
## Usage
|
||||
@@ -21,7 +18,7 @@ Create the filter:
|
||||
{{ $filter := images.Invert }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,23 +3,19 @@ title: images.Mask
|
||||
description: Returns an image filter that applies a mask to the source image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Mask RESOURCE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Mask RESOURCE]
|
||||
---
|
||||
|
||||
{{< new-in 0.141.0 />}}
|
||||
|
||||
The `images.Mask` filter applies a mask to an image. Black pixels in the mask make the corresponding areas of the base image transparent, while white pixels keep them opaque. Color images are converted to grayscale for masking purposes. The mask is automatically resized to match the dimensions of the base image.
|
||||
|
||||
{{% note %}}
|
||||
Of the formats supported by Hugo's imaging pipelie, only PNG and WebP have an alpha channel to support transparency. If your source image has a different format and you require transparent masked areas, convert it to either PNG or WebP as shown in the example below.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> Of the formats supported by Hugo's imaging pipeline, only PNG and WebP have an alpha channel to support transparency. If your source image has a different format and you require transparent masked areas, convert it to either PNG or WebP as shown in the example below.
|
||||
|
||||
When applying a mask to a non-transparent image format such as JPEG, the masked areas will be filled with the color specified by the `bgColor` parameter in your [site configuration]. You can override that color with a `Process` image filter:
|
||||
|
||||
@@ -27,8 +23,6 @@ When applying a mask to a non-transparent image format such as JPEG, the masked
|
||||
{{ $filter := images.Process "#00ff00" }}
|
||||
```
|
||||
|
||||
[site configuration]: /content-management/image-processing/#imaging-configuration
|
||||
|
||||
## Usage
|
||||
|
||||
Create a slice of filters, one for WebP conversion and the other for mask application:
|
||||
@@ -59,9 +53,6 @@ You can also apply the filter using the [`Filter`] method on a 'Resource' object
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
[`images.Filter`]: /functions/images/filter/
|
||||
[`Filter`]: /methods/resource/filter/
|
||||
|
||||
## Example
|
||||
|
||||
Mask
|
||||
@@ -78,3 +69,7 @@ Mask
|
||||
filterArgs="images/examples/mask.png"
|
||||
example=true
|
||||
>}}
|
||||
|
||||
[`Filter`]: /methods/resource/filter/
|
||||
[`images.Filter`]: /functions/images/filter/
|
||||
[site configuration]: /configuration/imaging/
|
||||
|
@@ -3,14 +3,11 @@ title: images.Opacity
|
||||
description: Returns an image filter that changes the opacity of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Opacity OPACITY]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Opacity OPACITY]
|
||||
---
|
||||
|
||||
{{< new-in 0.119.0 />}}
|
||||
@@ -25,7 +22,7 @@ Create the filter:
|
||||
{{ $filter := images.Opacity 0.65 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
The `images.Opacity` filter is most useful for target formats such as PNG and WebP that support transparency. If the source image does not support transparency, combine this filter with the `images.Process` filter:
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Overlay
|
||||
description: Returns an image filter that overlays the source image at the given coordinates, relative to the upper left corner.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Overlay RESOURCE X Y]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Overlay RESOURCE X Y]
|
||||
---
|
||||
|
||||
## Usage
|
||||
@@ -35,7 +32,7 @@ Create the filter:
|
||||
{{ $filter := images.Overlay $overlay 20 20 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Padding
|
||||
description: Returns an image filter that resizes the image canvas without resizing the image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: ['images.Padding V1 [V2] [V3] [V4] [COLOR]']
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: ['images.Padding V1 [V2] [V3] [V4] [COLOR]']
|
||||
---
|
||||
|
||||
{{< new-in 0.120.0 />}}
|
||||
@@ -28,7 +25,7 @@ Create the filter:
|
||||
{{ $filter := images.Padding 20 40 "#976941" }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
Combine with the [`Colors`] method to create a border with one of the image's most dominant colors:
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Pixelate
|
||||
description: Returns an image filter that applies a pixelation effect to an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Pixelate SIZE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Pixelate SIZE]
|
||||
---
|
||||
|
||||
## Usage
|
||||
@@ -21,7 +18,7 @@ Create the filter:
|
||||
{{ $filter := images.Pixelate 4 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,15 +3,11 @@ title: images.Process
|
||||
description: Returns an image filter that processes the given image using the given specification.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
- methods/resource/Process
|
||||
returnType: images.filter
|
||||
signatures: [images.Process SPEC]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Process SPEC]
|
||||
---
|
||||
|
||||
{{< new-in 0.119.0 />}}
|
||||
@@ -101,7 +97,7 @@ Create a filter:
|
||||
{{ $filter := images.Process "resize 256x q40 webp" }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -2,13 +2,11 @@
|
||||
title: images.QR
|
||||
description: Encodes the given text into a QR code using the specified options, returning an image resource.
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related: []
|
||||
returnType: images.ImageResource
|
||||
signatures: ['images.QR TEXT [OPTIONS]']
|
||||
toc: true
|
||||
math: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.ImageResource
|
||||
signatures: ['images.QR TEXT [OPTIONS]']
|
||||
---
|
||||
|
||||
{{< new-in 0.141.0 />}}
|
||||
@@ -21,19 +19,17 @@ The `images.QR` function encodes the given text into a [QR code] using the speci
|
||||
|
||||
Although the default option values are sufficient for most applications, you should test the rendered QR code both on-screen and in print.
|
||||
|
||||
[QR code]: https://en.wikipedia.org/wiki/QR_code
|
||||
|
||||
## Options
|
||||
|
||||
level
|
||||
: (`string`) The error correction level to use when encoding the text, one of `low`, `medium`, `quartile`, or `high`. Default is `medium`.
|
||||
|
||||
Error correction level|Redundancy
|
||||
:--|:--|:--
|
||||
low|20%
|
||||
medium|38%
|
||||
quartile|55%
|
||||
high|65%
|
||||
Error correction level|Redundancy
|
||||
:--|:--|:--
|
||||
low|20%
|
||||
medium|38%
|
||||
quartile|55%
|
||||
high|65%
|
||||
|
||||
scale
|
||||
: (`int`) The number of image pixels per QR code module. Must be greater than or equal to `2`. Default is `4`.
|
||||
@@ -41,8 +37,6 @@ scale
|
||||
targetDir
|
||||
: (`string`) The subdirectory within the [`publishDir`] where Hugo will place the generated image. Use Unix-style slashes (`/`) to separarate path segments. If empty or not provided, the image is placed directly in the `publishDir` root. Hugo automatically creates the necessary subdirectories if they don't exist.
|
||||
|
||||
[`publishDir`]: /getting-started/configuration/#publishdir
|
||||
|
||||
## Examples
|
||||
|
||||
To create a QR code using the default values for `level` and `scale`:
|
||||
@@ -74,7 +68,7 @@ Specify `level`, `scale`, and `targetDir` as needed to achieve the desired resul
|
||||
|
||||
To include a QR code that points to the `Permalink` of the current page:
|
||||
|
||||
{{< code file=layouts/_default/single.html >}}
|
||||
```go-html-template {file="layouts/_default/single.html"}
|
||||
{{ with images.QR .Permalink }}
|
||||
<img
|
||||
src="{{ .RelPermalink }}"
|
||||
@@ -85,7 +79,7 @@ To include a QR code that points to the `Permalink` of the current page:
|
||||
loading="lazy"
|
||||
>
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
```
|
||||
|
||||
Then hide the QR code with CSS unless printing the page:
|
||||
|
||||
@@ -116,9 +110,8 @@ If the QR code will be printed, use the default `scale` value of `4` pixels per
|
||||
|
||||
Avoid using Hugo's image processing methods to resize QR codes. Resizing can introduce blurring due to anti-aliasing when a QR code module occupies a fractional number of pixels.
|
||||
|
||||
{{% note %}}
|
||||
Always test the rendered QR code both on-screen and in print.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> Always test the rendered QR code both on-screen and in print.
|
||||
|
||||
## Shortcode
|
||||
|
||||
@@ -140,4 +133,6 @@ https://gohugo.io
|
||||
|
||||
The `qr` shortcode accepts several arguments including `level` and `scale`. See the [related documentation] for details.
|
||||
|
||||
[`publishDir`]: /configuration/all/#publishdir
|
||||
[QR code]: https://en.wikipedia.org/wiki/QR_code
|
||||
[related documentation]: /shortcodes/qr/
|
||||
|
@@ -3,14 +3,11 @@ title: images.Saturation
|
||||
description: Returns an image filter that changes the saturation of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Saturation PERCENTAGE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Saturation PERCENTAGE]
|
||||
---
|
||||
|
||||
The percentage must be in the range [-100, 500] where 0 has no effect.
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.Saturation 65 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Sepia
|
||||
description: Returns an image filter that produces a sepia-toned version of an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Sepia PERCENTAGE]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Sepia PERCENTAGE]
|
||||
---
|
||||
|
||||
The percentage must be in the range [0, 100] where 0 has no effect.
|
||||
@@ -23,7 +20,7 @@ Create the filter:
|
||||
{{ $filter := images.Sepia 75 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Sigmoid
|
||||
description: Returns an image filter that changes the contrast of an image using a sigmoidal function.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.Sigmoid MIDPOINT FACTOR]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.Sigmoid MIDPOINT FACTOR]
|
||||
---
|
||||
|
||||
This is a non-linear contrast change useful for photo adjustments; it preserves highlight and shadow detail.
|
||||
@@ -27,7 +24,7 @@ Create the filter:
|
||||
{{ $filter := images.Sigmoid 0.6 -4 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -3,14 +3,11 @@ title: images.Text
|
||||
description: Returns an image filter that adds text to an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: ['images.Text TEXT [OPTIONS]']
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: ['images.Text TEXT [OPTIONS]']
|
||||
---
|
||||
|
||||
## Options
|
||||
@@ -18,7 +15,7 @@ toc: true
|
||||
Although none of the options are required, at a minimum you will want to set the `size` to be some reasonable percentage of the image height.
|
||||
|
||||
alignx
|
||||
{{< new-in 0.141.0 />}}
|
||||
: {{< new-in 0.141.0 />}}
|
||||
: (`string`) The horizontal alignment of the text relative to the horizontal offset, one of `left`, `center`, or `right`. Default is `left`.
|
||||
|
||||
color
|
||||
@@ -27,8 +24,6 @@ color
|
||||
font
|
||||
: (`resource.Resource`) The font can be a [global resource](g), a [page resource](g), or a [remote resource](g). Default is [Go Regular], a proportional sans-serif TrueType font.
|
||||
|
||||
[Go Regular]: https://go.dev/blog/go-fonts#sans-serif
|
||||
|
||||
linespacing
|
||||
: (`int`) The number of pixels between each line. For a line height of 1.4, set the `linespacing` to 0.4 multiplied by the `size`. Default is `2`.
|
||||
|
||||
@@ -41,6 +36,8 @@ x
|
||||
y
|
||||
: (`int`) The vertical offset, in pixels, relative to the top of the image. Default is `10`.
|
||||
|
||||
[Go Regular]: https://go.dev/blog/go-fonts#sans-serif
|
||||
|
||||
## Usage
|
||||
|
||||
Set the text and paths:
|
||||
|
@@ -3,14 +3,11 @@ title: images.UnsharpMask
|
||||
description: Returns an image filter that sharpens an image.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.UnsharpMask SIGMA AMOUNT THRESHOLD]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: images.filter
|
||||
signatures: [images.UnsharpMask SIGMA AMOUNT THRESHOLD]
|
||||
---
|
||||
|
||||
The sigma argument is used in a gaussian function and affects the radius of effect. Sigma must be positive. The sharpen radius is approximately 3 times the sigma value.
|
||||
@@ -27,7 +24,7 @@ Create the filter:
|
||||
{{ $filter := images.UnsharpMask 10 0.4 0.03 }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
{{% include "/_common/functions/images/apply-image-filter.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
@@ -1,13 +0,0 @@
|
||||
---
|
||||
cascade:
|
||||
_build:
|
||||
list: never
|
||||
publishResources: false
|
||||
render: never
|
||||
---
|
||||
|
||||
<!--
|
||||
Files within this headless branch bundle are Markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
|
||||
|
||||
Include the rendered content using the "include" shortcode.
|
||||
-->
|
@@ -1,27 +0,0 @@
|
||||
---
|
||||
_comment: Do not remove front matter.
|
||||
---
|
||||
|
||||
Apply the filter using the [`images.Filter`] function:
|
||||
|
||||
[`images.Filter`]: /functions/images/filter/
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with . | images.Filter $filter }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
You can also apply the filter using the [`Filter`] method on a `Resource` object:
|
||||
|
||||
[`Filter`]: /methods/resource/filter/
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with .Filter $filter }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
@@ -4,9 +4,4 @@ linkTitle: images
|
||||
description: Use these functions to create an image filter, apply an image filter to an image, and to retrieve image information.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these functions to create an image filter, apply an image filter to an image, and to retrieve image information.
|
||||
|
Reference in New Issue
Block a user