mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-21 04:31:25 +00:00
use resize.Thumbnail mode instead of calculating size
This commit is contained in:
parent
26b3c21aa7
commit
c1ffd71e25
4
txt.go
4
txt.go
@ -194,9 +194,7 @@ func smallGif(src []byte) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("image decode problem: %v", err)
|
return nil, fmt.Errorf("image decode problem: %v", err)
|
||||||
}
|
}
|
||||||
if img.Bounds().Max.X-img.Bounds().Min.X > *txtImgSize { // this should come from the form
|
img = resize.Thumbnail(uint(*txtImgSize), uint(*txtImgSize), img, resize.NearestNeighbor)
|
||||||
img = resize.Resize(uint(*txtImgSize), 0, img, resize.NearestNeighbor)
|
|
||||||
}
|
|
||||||
var gifBuf bytes.Buffer
|
var gifBuf bytes.Buffer
|
||||||
err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{})
|
err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user