forked from deiwin/imstor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
43 lines (36 loc) · 823 Bytes
/
config.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
package imstor
import (
"image"
"io"
"github.com/deiwin/gonfigure"
)
var (
rootPathEnvProperty = gonfigure.NewRequiredEnvProperty("IMSTOR_ROOT_PATH")
)
type Config struct {
RootPath string
CopySizes []Size
Formats []Format
}
func NewConfig(copySizes []Size, formats []Format) *Config {
return &Config{
RootPath: rootPathEnvProperty.Value(),
CopySizes: copySizes,
Formats: formats,
}
}
// Size specifies a set of dimensions and a name that a copy of an image will
// be stored as
type Size struct {
Name string
Height uint
Width uint
}
// A Format describes how an image of a certaing mimetype can be decoded and
// then encoded.
type Format interface {
DecodableMediaType() string
Decode(io.Reader) (image.Image, error)
Encode(io.Writer, image.Image) error
EncodedExtension() string
}