-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions_test.go
More file actions
26 lines (23 loc) · 865 Bytes
/
options_test.go
File metadata and controls
26 lines (23 loc) · 865 Bytes
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
package imageprocess
import (
"fmt"
"image/color"
"testing"
)
func Test_ParseOptions(t *testing.T) {
options, err := ParseOptions("image/watermark,t_20,g_center,x_10,y_10,text_hello watermark,color_1366ec,size_200")
if err != nil {
t.Error(err)
}
fmt.Println(options)
}
func Test_SerializeOptions(t *testing.T) {
optionMap := make([]Option, 0)
// optionMap = append(optionMap, Option{Blur, BlurOption{Radius: 10}})
optionMap = append(optionMap, Option{Resize, ResizeOption{ResizeMode: Pad, Width: 100, Height: 100, Color: &color.RGBA{R: 255, G: 255, B: 0, A: 255}}})
optionMap = append(optionMap, Option{Watermark, TextWatermarkOption{WatermarkOption: WatermarkOption{
Opacity: 20, Position: Center, X: 10, Y: 10,
}, Color: &color.RGBA{0, 0, 0, 1}, Size: 200, Text: "hello watermark"}})
res := SerializeOptions(optionMap)
t.Logf("%s\n", res)
}