mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
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
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
34dc06b032
commit
e5856e61d8
@@ -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.
|
||||
|
Reference in New Issue
Block a user