mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-14 09:55:56 -07:00
parent
63f4b01c8d
commit
61997bc68b
7 changed files with 107 additions and 53 deletions
32
options.go
32
options.go
|
|
@ -1,5 +1,11 @@
|
|||
package bimg
|
||||
|
||||
/*
|
||||
#cgo pkg-config: vips
|
||||
#include "vips/vips.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const QUALITY = 80
|
||||
|
||||
type Gravity int
|
||||
|
|
@ -16,6 +22,26 @@ func (i Interpolator) String() string {
|
|||
return interpolations[i]
|
||||
}
|
||||
|
||||
type Rotation struct {
|
||||
angle int
|
||||
}
|
||||
|
||||
func (a Rotation) calculate() int {
|
||||
angle := a.angle
|
||||
divisor := angle % 90
|
||||
if divisor != 0 {
|
||||
angle = a.angle - divisor
|
||||
}
|
||||
return angle
|
||||
}
|
||||
|
||||
type Direction int
|
||||
|
||||
const (
|
||||
HORIZONTAL Direction = C.VIPS_DIRECTION_HORIZONTAL
|
||||
VERTICAL Direction = C.VIPS_DIRECTION_VERTICAL
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Height int
|
||||
Width int
|
||||
|
|
@ -23,7 +49,9 @@ type Options struct {
|
|||
Enlarge bool
|
||||
Extend int
|
||||
Embed bool
|
||||
Interpolator Interpolator
|
||||
Gravity Gravity
|
||||
Quality int
|
||||
Rotate int
|
||||
Flip Direction
|
||||
Gravity Gravity
|
||||
Interpolator Interpolator
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue