-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoption.go
44 lines (38 loc) · 858 Bytes
/
option.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
package himage
import (
"errors"
)
// Anchor is the anchor point for image alignment.
// It has been taken from the repo github.com/disintegration/imaging for easy access to the package.
type Anchor int
// Anchor point positions.
// It has been taken from the repo github.com/disintegration/imaging for easy access to the package.
const (
Center Anchor = iota
TopLeft
Top
TopRight
Left
Right
BottomLeft
Bottom
BottomRight
)
// Resize ..
type Resize struct {
Anchor Anchor
Ratio int
Width int
Height int
WidthOriented bool
HeightOriented bool
Maximize bool
Minimize bool
}
// Valid ..
func (r Resize) Valid() error {
if (r.Ratio > 0 && r.Width > 0) || (r.Ratio > 0 && r.Height > 0) {
return errors.New("both ratio and resolution cannot be specified at the same time")
}
return nil
}