davidbyttow / govips

A lightning fast image processing and resizing library for Go
MIT License
1.25k stars 196 forks source link

[BUG] SetPages method do nothing #375

Open g-mero opened 1 year ago

g-mero commented 1 year ago

// 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.

songjiayang commented 1 year ago

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