调整图像大小

调整图像大小,第1张

调整图像大小

阅读http://golang.org/pkg/image

// you need the image package, and a format package for encoding/decodingimport (    "bytes"    "image"    "image/jpeg" // if you don't need to use jpeg.Enpre, use this line instead     // _ "image/jpeg"    "github.com/nfnt/resize")// Decoding gives you an Image.// If you have an io.Reader already, you can give that to Depre // without reading it into a []byte.image, _, err := image.Depre(bytes.NewReader(data))// check errnewImage := resize.Resize(160, 0, original_image, resize.Lanczos3)// Enpre uses a Writer, use a Buffer if you need the raw []byteerr = jpeg.Enpre(someWriter, newImage, nil)// check err


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5476399.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存