aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/images/config.go
diff options
context:
space:
mode:
authorJ. Ansorg <[email protected]>2019-09-21 16:50:27 +0200
committerBjørn Erik Pedersen <[email protected]>2019-09-21 16:50:27 +0200
commite5856e61d88ef5149582851b00e06b5b93dce9f8 (patch)
tree5cfa1d63c34fbca7c4c226827dc574794edd4ecd /resources/images/config.go
parent34dc06b032741abac342d7a2a77510ded9b72ae8 (diff)
downloadhugo-e5856e61d88ef5149582851b00e06b5b93dce9f8.tar.gz
hugo-e5856e61d88ef5149582851b00e06b5b93dce9f8.zip
resources: Support output image format in image operations
The image format is defined as the image extension of the known formats, excluding the dot. All of 'img.Resize "600x jpeg"', 'img.Resize "600x jpg"', and 'img.Resize "600x png"' are valid format definitions. If the target format is defined in the operation definition string, then the converted image will be stored in this format. Permalinks and media type are updated correspondingly. Unknown image extensions in the operation definition have not effect. See #6298
Diffstat (limited to 'resources/images/config.go')
-rw-r--r--resources/images/config.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/resources/images/config.go b/resources/images/config.go
index a290922ab..6bc701bfe 100644
--- a/resources/images/config.go
+++ b/resources/images/config.go
@@ -187,7 +187,8 @@ func DecodeImageConfig(action, config string, defaults Imaging) (ImageConfig, er
} else {
return c, errors.New("invalid image dimensions")
}
-
+ } else if f, ok := ImageFormatFromExt("." + part); ok {
+ c.TargetFormat = f
}
}
@@ -212,6 +213,9 @@ func DecodeImageConfig(action, config string, defaults Imaging) (ImageConfig, er
// ImageConfig holds configuration to create a new image from an existing one, resize etc.
type ImageConfig struct {
+ // This defines the output format of the output image. It defaults to the source format
+ TargetFormat Format
+
Action string
// If set, this will be used as the key in filenames etc.