You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/content-management/image-processing/index.md
+84-15Lines changed: 84 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ date: 2018-01-24T13:10:00-05:00
5
5
lastmod: 2018-01-26T15:59:07-05:00
6
6
linktitle: "Image Processing"
7
7
categories: ["content management"]
8
-
keywords: [bundle,content,resources,images]
8
+
keywords: [resources,images]
9
9
weight: 4004
10
10
draft: false
11
11
toc: true
@@ -19,10 +19,8 @@ menu:
19
19
20
20
The `image` is a [Page Resource]({{< relref "/content-management/page-resources" >}}), and the processing methods listed below does not work on images inside your `/static` folder.
21
21
22
-
23
22
To get all images in a [Page Bundle]({{< relref "/content-management/organization#page-bundles" >}}):
24
23
25
-
26
24
```go-html-template
27
25
{{ with .Resources.ByType "image" }}
28
26
{{ end }}
@@ -32,10 +30,11 @@ To get all images in a [Page Bundle]({{< relref "/content-management/organizatio
32
30
## Image Processing Methods
33
31
34
32
35
-
The `image` resource implements the methods `Resize`, `Fit` and `Fill`, each returning the transformed image using the specified dimensions and processing options.
33
+
The `image` resource implements the methods `Resize`, `Fit` and `Fill`, each returning the transformed image using the specified dimensions and processing options. The `image` resource also, since Hugo 0.58, implements the method `Exif` and `Filter`.
34
+
35
+
### Resize
36
36
37
-
Resize
38
-
: Resizes the image to the specified width and height.
37
+
Resizes the image to the specified width and height.
39
38
40
39
```go
41
40
// Resize to a width of 600px and preserve ratio
@@ -48,24 +47,75 @@ Resize
48
47
{{ $image:= $resource.Resize"600x400" }}
49
48
```
50
49
51
-
Fit
52
-
: Scale down the image to fit the given dimensions while maintaining aspect ratio. Both height and width are required.
50
+
### Fit
51
+
Scale down the image to fit the given dimensions while maintaining aspect ratio. Both height and width are required.
53
52
54
53
```go
55
54
{{ $image:= $resource.Fit"600x400" }}
56
55
```
57
56
58
-
Fill
59
-
: Resize and crop the image to match the given dimensions. Both height and width are required.
57
+
### Fill
58
+
Resize and crop the image to match the given dimensions. Both height and width are required.
60
59
61
60
```go
62
61
{{ $image:= $resource.Fill"600x400" }}
63
62
```
64
63
64
+
### Filter
65
+
66
+
Apply one or more filters to your image. See [Image Filters](/functions/images/#image-filters) for a full list.
Provides an [Exif](https://en.wikipedia.org/wiki/Exif) object with metadata about the image.
91
+
92
+
Note that this is only suported for JPG and TIFF images, so it's recommended to wrap the access with a `with`, e.g.:
93
+
94
+
```go-html-template
95
+
{{ with $img.Exif }}
96
+
Date: {{ .Date }}
97
+
Lat/Long: {{ .Lat}}/{{ .Long }}
98
+
Tags:
99
+
{{ range $k, $v := .Tags }}
100
+
TAG: {{ $k }}: {{ $v }}
101
+
{{ end }}
102
+
```
103
+
104
+
#### Exif fields
105
+
106
+
Data
107
+
: "photo taken" date/time
108
+
109
+
Lat
110
+
: "photo taken where", GPS latitude
111
+
112
+
Long
113
+
: "photo taken where", GPS longitude
114
+
115
+
See [Image Processing Config](#image-processing-config) for how to configure what gets included in Exif.
116
+
117
+
65
118
66
-
{{% note %}}
67
-
Image operations in Hugo currently **do not preserve EXIF data** as this is not supported by Go's [image package](https://github.com/golang/go/search?q=exif&type=Issues&utf8=%E2%9C%93). This will be improved on in the future.
68
-
{{% /note %}}
69
119
70
120
71
121
## Image Processing Options
@@ -160,9 +210,28 @@ quality = 75
160
210
# Valid values are Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight
161
211
anchor = "smart"
162
212
163
-
```
213
+
[imaging.exif]
214
+
# Regexp matching the fields you want to Exclude from the (massive) set of Exif info
215
+
# available. As we cache this info to disk, this is for performance and
216
+
# disk space reasons more than anything.
217
+
# If you want it all, put ".*" in this config setting.
218
+
# Note that if neither this or ExcludeFields is set, Hugo will return a small
219
+
# default set.
220
+
includeFields = ""
164
221
165
-
All of the above settings can also be set per image procecssing.
222
+
# Regexp matching the Exif fields you want to exclude. This may be easier to use
223
+
# than IncludeFields above, depending on what you want.
224
+
excludeFields = ""
225
+
226
+
# Hugo extracts the "photo taken" date/time into .Date by default.
227
+
# Set this to true to turn it off.
228
+
disableDate = false
229
+
230
+
# Hugo extracts the "photo taken where" (GPS latitude and longitude) into
231
+
# .Long and .Lat. Set this to true to turn it off.
0 commit comments