From 03e607a6e7748611438001b5a4b46ba64a1f1c52 Mon Sep 17 00:00:00 2001 From: qinghuan Date: Mon, 15 Apr 2024 22:02:32 +0800 Subject: [PATCH] fix: bug in SetPages --- vips/image.go | 2 +- vips/image_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/vips/image.go b/vips/image.go index 20afe99e..01aba400 100644 --- a/vips/image.go +++ b/vips/image.go @@ -766,7 +766,7 @@ func (r *ImageRef) SetPages(pages int) error { return err } - vipsSetImageNPages(r.image, pages) + vipsSetImageNPages(out, pages) r.setImage(out) return nil diff --git a/vips/image_test.go b/vips/image_test.go index 4783a2f4..987942cc 100644 --- a/vips/image_test.go +++ b/vips/image_test.go @@ -1169,6 +1169,18 @@ func TestImageRef_HistogramEntropy(t *testing.T) { require.True(t, e > 0) } +func TestImageRef_SetPages(t *testing.T) { + Startup(nil) + + image, err := NewImageFromFile(resources + "gif-animated.gif") + require.NoError(t, err) + require.Equal(t, 8, image.Pages()) + + err = image.SetPages(3) + require.NoError(t, err) + require.Equal(t, 3, image.Pages()) +} + // TODO unit tests to cover: // NewImageFromReader failing test // NewImageFromFile failing test