-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
97 lines (85 loc) · 2.15 KB
/
options.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package watermark
import (
"image"
"image/jpeg"
)
var (
defaultWatermarkTextColor = image.Black
defaultWatermarkBackgroundColor = image.White
defaultJpegOptions = &jpeg.Options{Quality: 95}
defaultWatermarkOpacity = 128
)
const ()
type Options struct {
WatermarkHPercent float64
WatermarkWPercent float64
WatermarkHorizontalOffset int
WatermarkVerticalOffset int
WatermarkTextHorizontalOffset int
WatermarkTextVerticalOffset int
WatermarkTextColor *image.Uniform
WatermarkBackgroundColor *image.Uniform
WatermarkOpacity uint8
JpegOptions *jpeg.Options
AutoOrientation bool
RowSpacing float64
DPI float64
MaxFontSize float64
}
func (o *Options) watermarkHPercent() float64 {
return o.WatermarkHPercent
}
func (o *Options) watermarkWPercent() float64 {
return o.WatermarkWPercent
}
func (o *Options) watermarkHorizontalOffset() int {
return o.WatermarkHorizontalOffset
}
func (o *Options) watermarkVerticalOffset() int {
return o.WatermarkVerticalOffset
}
func (o *Options) watermarkTextHorizontalOffset() int {
return o.WatermarkTextHorizontalOffset
}
func (o *Options) watermarkTextVerticalOffset() int {
return o.WatermarkTextVerticalOffset
}
func (o *Options) watermarkTextColor() *image.Uniform {
if o.WatermarkTextColor == nil {
return defaultWatermarkTextColor
}
return o.WatermarkTextColor
}
func (o *Options) watermarkBackgroundColor() *image.Uniform {
if o.WatermarkBackgroundColor == nil {
return defaultWatermarkBackgroundColor
}
return o.WatermarkBackgroundColor
}
func (o *Options) watermarkOpacity() uint8 {
if o.WatermarkOpacity == 0 {
return uint8(defaultWatermarkOpacity)
}
return o.WatermarkOpacity
}
func (o *Options) jpegOptions() *jpeg.Options {
if o.JpegOptions == nil {
return defaultJpegOptions
}
return o.JpegOptions
}
func (o *Options) autoOrientation() bool {
return o.AutoOrientation
}
func (o *Options) rowSpacing() float64 {
return o.RowSpacing
}
func (o *Options) dpi() float64 {
return o.DPI
}
func (o *Options) maxFontSize() float64 {
if o.MaxFontSize == 0 {
return 200
}
return o.MaxFontSize
}