@@ -14,14 +14,29 @@ type (
14
14
15
15
ImageResizeRequest struct {
16
16
File string
17
- Width int `form:"width"`
18
- Height int `form:"height"`
19
- Crop bool `form:"crop"`
17
+ Width int
18
+ Height int
19
+ Format string
20
20
}
21
21
22
22
ImageResizeResponse struct {
23
23
* Download
24
24
}
25
+
26
+ ImageWatermarkRequest struct {
27
+ File string
28
+ Text string
29
+ Font string
30
+ Size int
31
+ Color string
32
+ Opacity int
33
+ Position string
34
+ Margin int
35
+ }
36
+
37
+ ImageWatermarkResponse struct {
38
+ * Download
39
+ }
25
40
)
26
41
27
42
func (c * Client ) ImageCompress (req * ImageCompressRequest ) (res * ImageCompressResponse , err * APIError ) {
@@ -45,7 +60,7 @@ func (c *Client) ImageResize(req *ImageResizeRequest) (res *ImageResizeResponse,
45
60
SetFormData (map [string ]string {
46
61
"width" : strconv .Itoa (req .Width ),
47
62
"height" : strconv .Itoa (req .Height ),
48
- "crop " : strconv . FormatBool ( req .Crop ) ,
63
+ "format " : req .Format ,
49
64
}).
50
65
SetResult (res ).
51
66
SetError (err ).
@@ -56,3 +71,26 @@ func (c *Client) ImageResize(req *ImageResizeRequest) (res *ImageResizeResponse,
56
71
}
57
72
return
58
73
}
74
+
75
+ func (c * Client ) ImageWatermark (req * ImageWatermarkRequest ) (res * ImageWatermarkResponse , err * APIError ) {
76
+ res = new (ImageWatermarkResponse )
77
+ _ , e := c .resty .R ().
78
+ SetFile ("file" , req .File ).
79
+ SetFormData (map [string ]string {
80
+ "text" : req .Text ,
81
+ "font" : req .Font ,
82
+ "size" : strconv .Itoa (req .Size ),
83
+ "color" : req .Color ,
84
+ "opacity" : strconv .Itoa (req .Opacity ),
85
+ "position" : req .Position ,
86
+ "margin" : strconv .Itoa (req .Margin ),
87
+ }).
88
+ SetResult (res ).
89
+ SetError (err ).
90
+ Post ("/image/watermark" )
91
+ if e != nil {
92
+ err = new (APIError )
93
+ err .Message = e .Error ()
94
+ }
95
+ return
96
+ }
0 commit comments