Skip to content

Commit

Permalink
fix: bug in SetPages (#421)
Browse files Browse the repository at this point in the history
Co-authored-by: qinghuan <[email protected]>
  • Loading branch information
zhifengzhuang and qinghuan authored Apr 16, 2024
1 parent d2d2a1f commit bb678ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vips/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions vips/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb678ba

Please sign in to comment.