blob: 226fc0eddc9e9b37789dae182d5f47009830a3cb (
plain)
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
|
package thumbnail
import (
"context"
"github.com/RanXom/galleryd/internal/gallery"
)
// Generator creates thumbnails for gallery photos
type Generator struct {
cacheDir string
}
func New(cacheDir string) *Generator {
return &Generator{
cacheDir: cacheDir,
}
}
// Generate creates (or retrieves) a thumbnail
func (g *Generator) Generate(
ctx context.Context,
photo gallery.Photo,
) (Thumbnail, error) {
_, err := generateImage(photo)
if err != nil {
return Thumbnail{}, err
}
return Thumbnail{
Path: g.cachePath(photo),
}, nil
}
|