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