forked from h2non/bimg
/
options.go
176 lines (155 loc) · 5.07 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package bimg
/*
#cgo pkg-config: vips
#include "vips/vips.h"
*/
import "C"
const (
// Quality defines the default JPEG quality to be used.
Quality = 80
// MaxSize defines the maximum pixels width or height supported.
MaxSize = 16383
)
// Gravity represents the image gravity value.
type Gravity int
const (
// GravityCentre represents the centre value used for image gravity orientation.
GravityCentre Gravity = iota
// GravityNorth represents the north value used for image gravity orientation.
GravityNorth
// GravityEast represents the east value used for image gravity orientation.
GravityEast
// GravitySouth represents the south value used for image gravity orientation.
GravitySouth
// GravityWest represents the west value used for image gravity orientation.
GravityWest
)
// Interpolator represents the image interpolation value.
type Interpolator int
const (
// Bicubic interpolation value.
Bicubic Interpolator = iota
// Bilinear interpolation value.
Bilinear
// Nohalo interpolation value.
Nohalo
)
var interpolations = map[Interpolator]string{
Bicubic: "bicubic",
Bilinear: "bilinear",
Nohalo: "nohalo",
}
func (i Interpolator) String() string {
return interpolations[i]
}
// Angle represents the image rotation angle value.
type Angle int
const (
// D0 represents the rotation angle 0 degrees.
D0 Angle = 0
// D90 represents the rotation angle 90 degrees.
D90 Angle = 90
// D180 represents the rotation angle 180 degrees.
D180 Angle = 180
// D270 represents the rotation angle 270 degrees.
D270 Angle = 270
)
// Direction represents the image direction value.
type Direction int
const (
// Horizontal represents the orizontal image direction value.
Horizontal Direction = C.VIPS_DIRECTION_HORIZONTAL
// Vertical represents the vertical image direction value.
Vertical Direction = C.VIPS_DIRECTION_VERTICAL
)
// Interpretation represents the image interpretation type.
// See: http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/VipsImage.html#VipsInterpretation
type Interpretation int
const (
// InterpretationError points to the libvips interpretation error type.
InterpretationError Interpretation = C.VIPS_INTERPRETATION_ERROR
// InterpretationMultiband points to its libvips interpretation equivalent type.
InterpretationMultiband Interpretation = C.VIPS_INTERPRETATION_MULTIBAND
// InterpretationBW points to its libvips interpretation equivalent type.
InterpretationBW Interpretation = C.VIPS_INTERPRETATION_B_W
// InterpretationCMYK points to its libvips interpretation equivalent type.
InterpretationCMYK Interpretation = C.VIPS_INTERPRETATION_CMYK
// InterpretationRGB points to its libvips interpretation equivalent type.
InterpretationRGB Interpretation = C.VIPS_INTERPRETATION_RGB
// InterpretationSRGB points to its libvips interpretation equivalent type.
InterpretationSRGB Interpretation = C.VIPS_INTERPRETATION_sRGB
// InterpretationRGB16 points to its libvips interpretation equivalent type.
InterpretationRGB16 Interpretation = C.VIPS_INTERPRETATION_RGB16
// InterpretationGREY16 points to its libvips interpretation equivalent type.
InterpretationGREY16 Interpretation = C.VIPS_INTERPRETATION_GREY16
// InterpretationScRGB points to its libvips interpretation equivalent type.
InterpretationScRGB Interpretation = C.VIPS_INTERPRETATION_scRGB
// InterpretationLAB points to its libvips interpretation equivalent type.
InterpretationLAB Interpretation = C.VIPS_INTERPRETATION_LAB
// InterpretationXYZ points to its libvips interpretation equivalent type.
InterpretationXYZ Interpretation = C.VIPS_INTERPRETATION_XYZ
)
// WatermarkFont defines the default watermark font to be used.
var WatermarkFont = "sans 10"
// Color represents a traditional RGB color scheme.
type Color struct {
R, G, B uint8
}
// ColorBlack is a shortcut to black RGB color representation.
var ColorBlack = Color{0, 0, 0}
// Watermark represents the text-based watermark supported options.
type Watermark struct {
Width int
DPI int
Margin int
Opacity float32
NoReplicate bool
Text string
Font string
Background Color
}
// GaussianBlur represents the gaussian image transformation values.
type GaussianBlur struct {
Sigma float64
MinAmpl float64
}
// Sharpen represents the image sharp transformation options.
type Sharpen struct {
Radius int
X1 float64
Y2 float64
Y3 float64
M1 float64
M2 float64
}
// Options represents the supported image transformation options.
type Options struct {
Height int
Width int
AreaHeight int
AreaWidth int
Top int
Left int
Extend int
Quality int
Compression int
Zoom int
Crop bool
Enlarge bool
Embed bool
Flip bool
Flop bool
Force bool
NoAutoRotate bool
NoProfile bool
Interlace bool
Rotate Angle
Background Color
Gravity Gravity
Watermark Watermark
Type ImageType
Interpolator Interpolator
Interpretation Interpretation
GaussianBlur GaussianBlur
Sharpen Sharpen
}