Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Resize #34

Open
yuhang2 opened this issue Aug 31, 2020 · 1 comment
Open

Support Resize #34

yuhang2 opened this issue Aug 31, 2020 · 1 comment

Comments

@yuhang2
Copy link

yuhang2 commented Aug 31, 2020

Does this library support resize images?

@grokify
Copy link

grokify commented Oct 25, 2020

DecodeRGBA will return an *image.RGBA which can be resized using the standard draw package golang.org/x/image/draw.

The following should work:

m, err := webp.DecodeRGBA((data)
if err != nil {
	log.Fatal(err)
}

width := 100
height := 200
scale := draw.BiLinear

rect := image.Rect(0, 0, width, height)
dst := image.NewRGBA(rect)
scale.Scale(dst, rect, m, src.Bounds(), draw.Over, nil)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants