forked from tucnak/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.go
47 lines (43 loc) · 732 Bytes
/
image.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
36
37
38
39
40
41
42
43
44
45
46
47
package tgimage
const (
convert = "convert"
)
type Opt struct {
Width int
Height int
HardResize bool
Convert string
TempDir string
Quality int
}
func parseOpts(opts ...*Opt) Opt {
opt := Opt{
Width: 5000,
Height: 5000,
HardResize: false,
Convert: convert,
TempDir: "",
Quality: 95,
}
if len(opts) == 0 {
return opt
}
opts_ := opts[0]
if opts_.Width != 0 {
opt.Width = opts_.Width
}
if opts_.Height != 0 {
opt.Height = opts_.Height
}
if opts_.Convert != "" {
opt.Convert = opts_.Convert
}
if opts_.TempDir != "" {
opt.TempDir = opts_.TempDir
}
if opts_.Quality != 0 {
opt.Quality = opts_.Quality
}
opt.HardResize = opts_.HardResize
return opt
}