Skip to content

Commit 8ccaea1

Browse files
committed
Bumpled v0.17.0
Signed-off-by: Vishal Rana <[email protected]>
1 parent 20fef86 commit 8ccaea1

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

image.go

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,29 @@ type (
1414

1515
ImageResizeRequest struct {
1616
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
2020
}
2121

2222
ImageResizeResponse struct {
2323
*Download
2424
}
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+
}
2540
)
2641

2742
func (c *Client) ImageCompress(req *ImageCompressRequest) (res *ImageCompressResponse, err *APIError) {
@@ -45,7 +60,7 @@ func (c *Client) ImageResize(req *ImageResizeRequest) (res *ImageResizeResponse,
4560
SetFormData(map[string]string{
4661
"width": strconv.Itoa(req.Width),
4762
"height": strconv.Itoa(req.Height),
48-
"crop": strconv.FormatBool(req.Crop),
63+
"format": req.Format,
4964
}).
5065
SetResult(res).
5166
SetError(err).
@@ -56,3 +71,26 @@ func (c *Client) ImageResize(req *ImageResizeRequest) (res *ImageResizeResponse,
5671
}
5772
return
5873
}
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

Comments
 (0)