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/image_test.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/image_test.go')
-rw-r--r-- | resource/image_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/resource/image_test.go b/resource/image_test.go index e981a208f..1a937d56b 100644 --- a/resource/image_test.go +++ b/resource/image_test.go @@ -19,6 +19,8 @@ import ( "strconv" "testing" + "github.com/disintegration/imaging" + "sync" "github.com/stretchr/testify/require" @@ -258,6 +260,24 @@ func TestImageWithMetadata(t *testing.T) { } +func TestImageResize8BitPNG(t *testing.T) { + + assert := require.New(t) + + image := fetchImage(assert, "gohugoio.png") + + assert.Equal(imaging.PNG, image.format) + assert.Equal("/a/gohugoio.png", image.RelPermalink()) + assert.Equal("image", image.ResourceType()) + + resized, err := image.Resize("800x") + assert.NoError(err) + assert.Equal(imaging.PNG, resized.format) + assert.Equal("/a/gohugoio_hu0e1b9e4a4be4d6f86c7b37b9ccce3fbc_73886_800x0_resize_linear_1.png", resized.RelPermalink()) + assert.Equal(800, resized.Width()) + +} + func BenchmarkResizeParallel(b *testing.B) { assert := require.New(b) img := fetchSunset(assert) |