govips icon indicating copy to clipboard operation
govips copied to clipboard

[BUG] SetPages method do nothing

Open g-mero opened this issue 2 years ago • 1 comments

// SetPages sets the number of pages in the Image // For animated images this corresponds to the number of frames

func (r *ImageRef) SetPages(pages int) error {
	out, err := vipsCopyImage(r.image)
	if err != nil {
		return err
	}

	vipsSetImageNPages(r.image, pages)

	r.setImage(out)
	return nil
}

I attempted to use the SetPages method to keep only the first frame of an animated image and export it to a JPEG file, but it doesn't work. After reviewing the code, it appears to merely duplicate the original image.

g-mero avatar Jul 30 '23 09:07 g-mero

How about setting the page=1 in vips.ImportParams, then just load one page for animated images

songjiayang avatar Sep 03 '23 08:09 songjiayang