Debian Codegraph @

docs/content/en/configuration/imaging.md

raw
1 ---
2 title: Configure imaging
3 linkTitle: Imaging
4 description: Configure imaging.
5 categories: []
6 keywords: []
7 ---
8
9 These are the default settings for processing images:
10
11 {{< code-toggle config=imaging />}}
12
13 ## Top-level settings
14
15 These settings apply to all image formats.
16
17 `anchor`
18 : (`string`) The focal point used when cropping or filling an image. Valid case-insensitive options include `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. The `Smart` option utilizes the [`muesli/smartcrop`][] package to identify the most interesting area of the image. Default is `smart`.
19
20 `bgColor`
21 : (`string`) The background color used when converting transparent images to formats that do not support transparency, such as PNG to JPEG. This color also fills the empty space created when rotating an image by a non-orthogonal angle if the space is not transparent and a background color is not specified in the processing specification. The value must be an RGB [hexadecimal color][]. Default is `#ffffff`.
22
23 `compression`
24 : {{< deprecated-in 0.163.0 />}}
25 : Use the format-specific `compression` setting instead, applicable to [AVIF](#avif) and [WebP](#webp) images.
26
27 `hint`
28 : {{< deprecated-in 0.163.0 />}}
29 : Use the format-specific `hint` setting instead, applicable to [AVIF](#avif) and [WebP](#webp) images.
30
31 `quality`
32 : {{< deprecated-in 0.163.0 />}}
33 : Use the format-specific `quality` setting instead, applicable to [AVIF](#avif), [JPEG](#jpeg), and [WebP](#webp) images.
34
35 `resampleFilter`
36 : (`string`) The algorithm used to calculate new pixels when resizing, fitting, or filling an image. Common case-insensitive options include `box`, `lanczos`, `catmullRom`, `mitchellNetravali`, `linear`, or `nearestNeighbor`. Default is `box`.
37
38 Filter|Description
39 :--|:--
40 `box`|Simple and fast averaging filter appropriate for downscaling
41 `lanczos`|High-quality resampling filter for photographic images yielding sharp results
42 `catmullRom`|Sharp cubic filter that is faster than the Lanczos filter while providing similar results
43 `mitchellNetravali`|Cubic filter that produces smoother results with less ringing artifacts than CatmullRom
44 `linear`|Bilinear resampling filter, produces smooth output, faster than cubic filters
45 `nearestNeighbor`|Fastest resampling filter, no antialiasing
46
47 Refer to the [source documentation][] for a complete list of available resampling filters. If you wish to improve image quality at the expense of performance, you may wish to experiment with the alternative filters.
48
49 ## AVIF
50
51 {{< new-in 0.162.0 />}}
52
53 These settings apply when encoding AVIF images.
54
55 > [!NOTE]
56 > When exporting HDR AVIF images from Lightroom, in the Export dialog under File Settings, uncheck Maximize Compatibility to improve Hugo's AVIF decoding speed.
57
58 > [!NOTE]
59 > Encoding animated images to AVIF produces a single-frame (static) image. Converting an animated AVIF to another format such as GIF works as expected.
60
61 {{< code-toggle config=imaging.avif />}}
62
63 `compression`
64 : {{< new-in 0.163.0 />}}
65 : (`string`) The encoding strategy. Options are `lossy` or `lossless`. Default is `lossy`.
66
67 `encoderSpeed`
68 : (`int`) The encoder speed. Expressed as a whole number from `1` to `10`, inclusive, equivalent to the `-s` flag for the [`avifenc`][] CLI. Lower numbers reduce file size at the cost of build time. At typical web image sizes, quality is indistinguishable across settings. Values below `5` may cause significantly longer build times. Default is `10`.
69
70 `hint`
71 : {{< new-in 0.163.0 />}}
72 : (`string`) The content hint. Valid options include `drawing`, `icon`, `photo`, `picture`, or `text`. Hugo uses the `4:2:0` chroma subsampling format with `photo` and `picture`, and `4:4:4` with the remaining options. Default is `photo`.
73
74 Value|Example
75 :--|:--
76 `drawing`|Hand or line drawing with high-contrast details
77 `icon`|Small colorful image
78 `photo`|Outdoor photograph with natural lighting
79 `picture`|Indoor photograph such as a portrait
80 `text`|Image that is primarily text
81
82 `quality`
83 : {{< new-in 0.163.0 />}}
84 : (`int`) The visual fidelity when using `lossy` compression. Expressed as a whole number from `1` to `100`, inclusive. Lower numbers prioritize smaller file size, while higher numbers prioritize visual clarity. Default is `60`. Quality values are encoder-specific and not directly comparable across formats; a value of `60` for AVIF is perceptually similar to `75` for JPEG.
85
86 ## JPEG
87
88 {{< new-in 0.163.0 />}}
89
90 These settings apply when encoding JPEG images.
91
92 {{< code-toggle config=imaging.jpeg />}}
93
94 `quality`
95 : (`int`) The visual fidelity. Expressed as a whole number from `1` to `100`, inclusive. Lower numbers prioritize smaller file size, while higher numbers prioritize visual clarity. Default is `75`.
96
97 ## WebP
98
99 {{< new-in 0.155.0 />}}
100
101 These settings apply when encoding WebP images.
102
103 {{< code-toggle config=imaging.webp />}}
104
105 `compression`
106 : {{< new-in 0.163.0 />}}
107 : (`string`) The encoding strategy. Options are `lossy` or `lossless`. Default is `lossy`.
108
109 `hint`
110 : (`string`) The content hint, equivalent to the `-preset` flag for the [`cwebp`][] CLI. Valid options include `drawing`, `icon`, `photo`, `picture`, or `text`. Default is `photo`.
111
112 Value|Example
113 :--|:--
114 `drawing`|Hand or line drawing with high-contrast details
115 `icon`|Small colorful image
116 `photo`|Outdoor photograph with natural lighting
117 `picture`|Indoor photograph such as a portrait
118 `text`|Image that is primarily text
119
120 `method`
121 : (`int`) The effort level of the compression algorithm. Expressed as a whole number from `0` to `6`, inclusive, equivalent to the `-m` flag for the [`cwebp`][] CLI. Lower numbers prioritize processing speed, while higher numbers prioritize compression efficiency and image quality. Default is `2`.
122
123 `quality`
124 : {{< new-in 0.163.0 />}}
125 : (`int`) The visual fidelity when using `lossy` compression. Expressed as a whole number from `1` to `100`, inclusive. Lower numbers prioritize smaller file size, while higher numbers prioritize visual clarity. Default is `75`.
126
127 `useSharpYuv`
128 : (`bool`) The conversion method used for RGB-to-YUV encoding, equivalent to the `-sharp_yuv` flag for the [`cwebp`][] CLI. Enabling this prioritizes image sharpness at the expense of processing speed. Default is `false`.
129
130 ## Exif method
131
132 {{< deprecated-in 0.155.0 >}}
133 Use the [`Meta`](#meta-method) method instead.
134 {{< /deprecated-in >}}
135
136 ## Meta method
137
138 {{< new-in 0.155.0 />}}
139
140 The following parameters allow you to control how Hugo extracts and filters metadata when using the [`Meta`][] method, helping you balance data granularity with build performance.
141
142 `fields`
143 : (`[]string`) A [glob slice](g) matching the fields to include when extracting metadata. If empty, a default set excluding technical metadata is used. Set&nbsp;to&nbsp;`['**']`&nbsp;to include all fields.
144
145 > [!NOTE]
146 > By default, to improve performance and decrease cache size, Hugo excludes the following fields: `ColorSpace`, `Contrast`, `Exif`, `ExposureBias`, `ExposureMode`, `ExposureProgram`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`.
147
148 `sources`
149 : (`[]string`) The metadata sources to include, one or more of `exif`, `iptc`, or `xmp`. Default is `['exif', 'iptc']`. The XMP metadata is excluded by default to improve performance.
150
151 [`Meta`]: /methods/resource/meta/
152 [`avifenc`]: https://github.com/aomediacodec/libavif
153 [`cwebp`]: https://developers.google.com/speed/webp/docs/cwebp
154 [`muesli/smartcrop`]: https://github.com/muesli/smartcrop
155 [hexadecimal color]: https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color
156 [source documentation]: https://github.com/disintegration/imaging#image-resizing