diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-02-19 16:34:49 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-02-19 20:15:58 +0100 |
commit | 799c654b0d39ec869c2da24d41de3636eb7157f0 (patch) | |
tree | bfa501c44fe3aa91f1ae4e827f7625ba54ba79da /resource/resource.go | |
parent | faa3159e5e09e2a95cbef4dca5fcb9c8e2b41bf4 (diff) |
resource: Preserve color palette for PNG images
This commit will force a reprocessing of PNG images with new names, so it is adviced to run a `hugo --gc` to remove stale files.
Fixes #4416
Diffstat (limited to 'resource/resource.go')
-rw-r--r-- | resource/resource.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/resource/resource.go b/resource/resource.go index da62db65c..66fda4c1b 100644 --- a/resource/resource.go +++ b/resource/resource.go @@ -23,6 +23,8 @@ import ( "strings" "sync" + "github.com/disintegration/imaging" + "github.com/spf13/cast" "github.com/gobwas/glob" @@ -297,8 +299,16 @@ func (r *Spec) newResource( return nil, err } + ext := strings.ToLower(helpers.Ext(absSourceFilename)) + + imgFormat, ok := imageFormats[ext] + if !ok { + return nil, imaging.ErrUnsupportedFormat + } + return &Image{ hash: hash, + format: imgFormat, imaging: r.imaging, genericResource: gr}, nil } |