davidbyttow / govips

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

Refactoring Old and deprecated code #349

Closed Soul-Asylum closed 1 year ago

Soul-Asylum commented 1 year ago

Guys, I have a project that contains a very old code, referring to govips v1, and I need to refactor it, but I'm having a lot of difficulty, would anyone know how to help me?

`func ResizeImage(imageBuffer bytes.Buffer, width, height int) (bytes.Buffer, error) { imageRef, _ := vips.LoadImage(imageBuffer)

//msg := fmt.Sprintf("Initial image has width of %v and height of %v", imageRef.Width(), imageRef.Height())
//fmt.Println(msg)

imageBytes, _, err := vips.NewTransform().
    Image(imageRef).
    Interpretation(vips.InterpretationSRGB).
    PadStrategy(vips.ExtendWhite).
    Resize(width, height).
    Apply()

if err != nil {
    return nil, err
}

return bytes.NewBuffer(imageBytes), nil

}`

tonimelisma commented 1 year ago

Hey, thanks for the question. The API has been pretty completely revamped and doesn't support method chaining anymore. I recommend you just check the current documentation.