-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize_test.go
35 lines (32 loc) · 995 Bytes
/
resize_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package imageprocess
import (
"fmt"
"image/color"
"image/gif"
"os"
"testing"
)
// parseHexColor converts a hex color string to an image/color.RGBA.
func Test_ResizeImage(t *testing.T) {
// D:\work\notes\demo\example\image\go_demo\imaging\example.gif
img, f, err := LoadImage("examples/example.gif")
if err != nil {
t.Error(err)
}
fmt.Println(f)
op := ResizeOption{ResizeMode: Pad, Width: 10, Height: 100, Limit: 1, Color: &color.RGBA{R: 255, G: 255, B: 0, A: 255}}
img = ResizeImage(img, op)
file, _ := os.Create("examples/image_resize.gif")
EncodeImage(img, file, f, 100)
}
func Test_ResizeGif(t *testing.T) {
// D:\work\notes\demo\example\image\go_demo\imaging\example.gif
img, err := LoadGif("examples/example.gif")
if err != nil {
t.Error(err)
}
op := ResizeOption{ResizeMode: Pad, Width: 20, Height: 100, Limit: 1, Color: &color.RGBA{R: 255, G: 255, B: 0, A: 255}}
ResizeGif(img, op)
file, _ := os.Create("examples/image_resize.gif")
gif.EncodeAll(file, img)
}