-
Notifications
You must be signed in to change notification settings - Fork 0
/
processing.go
44 lines (34 loc) · 1.08 KB
/
processing.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
package main
import (
"github.com/disintegration/imaging"
"image"
)
// Does Preview Exist? (objectname, type)
// Read Original (objectname)
// Create PreviewBase, original for image files (objectname) (image)
// Generate Preview (io.Reader, previewType) (*image, type)
// Upload Preview (path)
// Redirect to Preview (objectname, type)
// When do I need to buffer Image
// - Not when creating on the fly preview
// - When creating multiple preview files
// - When preview base has to be created from content
// Translates previewTypes to Imaging functions. Returns image interface
func Preview(oimg *image.Image, opt PreviewOptions) (img image.Image, err error) {
if err != nil {
return img, err
}
if opt.Method == "resize" {
img = imaging.Resize(*oimg, opt.Width, opt.Height, imaging.Box)
} else {
img = imaging.Thumbnail(*oimg, opt.Width, opt.Height, imaging.Linear)
}
return // img and err are implicit
}
// Path of Preview file
// - Used to check if exists, uploading, redirecting
func PreviewPath(objname string, ptype string) (path string) {
return ""
}
func Generate() {
}