/
thumbnail.go
31 lines (24 loc) · 947 Bytes
/
thumbnail.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
// Copyright (c) 2017-2019 Carnegie Mellon University. All rights reserved.
// Use of this source code is governed by BSD 3-clause license.
package resolver
import (
"context"
"encoding/base64"
models "go.edusense.io/storage/models"
)
// ThumbnailResolver resolves query-agnostic Thumbnail model.
type ThumbnailResolver struct {
Thumbnail models.Thumbnail
}
// OriginalRows returns the original height of the source image (Rows).
func (t *ThumbnailResolver) OriginalRows(ctx context.Context) (int32, error) {
return int32(t.Thumbnail.Rows), nil
}
// OriginalCols returns the original weith of the source image (Cols).
func (t *ThumbnailResolver) OriginalCols(ctx context.Context) (int32, error) {
return int32(t.Thumbnail.Cols), nil
}
// Binary returns the base64 encoding of the thumbnail.
func (t *ThumbnailResolver) Binary(ctx context.Context) (string, error) {
return base64.StdEncoding.EncodeToString(t.Thumbnail.Binary), nil
}