-
Notifications
You must be signed in to change notification settings - Fork 9
/
iiif.go
60 lines (44 loc) · 1.42 KB
/
iiif.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
package process
import (
iiifuri "github.com/go-iiif/go-iiif-uri"
iiifcache "github.com/go-iiif/go-iiif/v5/cache"
iiifconfig "github.com/go-iiif/go-iiif/v5/config"
iiifdriver "github.com/go-iiif/go-iiif/v5/driver"
iiifimage "github.com/go-iiif/go-iiif/v5/image"
)
type IIIFProcessor struct {
Processor
config *iiifconfig.Config
driver iiifdriver.Driver
source_cache iiifcache.Cache
dest_cache iiifcache.Cache
}
func NewIIIFProcessor(config *iiifconfig.Config, driver iiifdriver.Driver) (Processor, error) {
return NewIIIFProcessorWithCaches(config, driver, nil, nil)
}
func NewIIIFProcessorWithCaches(config *iiifconfig.Config, driver iiifdriver.Driver, source_cache iiifcache.Cache, dest_cache iiifcache.Cache) (Processor, error) {
if source_cache == nil {
c, err := iiifcache.NewImagesCacheFromConfig(config)
if err != nil {
return nil, err
}
source_cache = c
}
if dest_cache == nil {
c, err := iiifcache.NewDerivativesCacheFromConfig(config)
if err != nil {
return nil, err
}
dest_cache = c
}
pr := IIIFProcessor{
config: config,
driver: driver,
source_cache: source_cache,
dest_cache: dest_cache,
}
return &pr, nil
}
func (pr *IIIFProcessor) ProcessURIWithInstructions(u iiifuri.URI, label Label, i IIIFInstructions) (iiifuri.URI, iiifimage.Image, error) {
return TransformURIWithInstructions(u, i, pr.config, pr.driver, pr.source_cache, pr.dest_cache)
}