forked from pressly/imgry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imgry.go
45 lines (36 loc) · 919 Bytes
/
imgry.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
package imgry
import "errors"
const (
VERSION = "0.40.0"
)
var (
ErrInvalidImageData = errors.New("invalid image data")
)
type Engine interface {
Version() string
Initialize(tmpDir string) error
Terminate()
LoadFile(filename string, srcFormat ...string) (Image, error)
LoadBlob(b []byte, srcFormat ...string) (Image, error)
GetImageInfo(b []byte, srcFormat ...string) (*ImageInfo, error)
}
type Image interface {
Data() []byte
Width() int
Height() int
Format() string
SetFormat(format string) error
Release()
Released() bool
SizeIt(sizing *Sizing) error
WriteToFile(string) error
}
type ImageInfo struct {
URL string `json:"url"`
Format string `json:"format"`
Mimetype string `json:"mimetype"`
Width int `json:"width"`
Height int `json:"height"`
AspectRatio float64 `json:"aspect_ratio"`
ContentLength int `json:"content_length"`
}