[READ-ONLY] Mirror of https://github.com/andrioid/s3preview. Preview serving microservice for s3. Generates and uploads any missing thumbnails. Redirects to existing.
0

Configure Feed

Select the types of activity you want to include in your feed.

s3preview / processing.go
1.1 kB 44 lines
1package main 2 3import ( 4 "github.com/disintegration/imaging" 5 "image" 6) 7 8// Does Preview Exist? (objectname, type) 9// Read Original (objectname) 10// Create PreviewBase, original for image files (objectname) (image) 11// Generate Preview (io.Reader, previewType) (*image, type) 12// Upload Preview (path) 13// Redirect to Preview (objectname, type) 14 15// When do I need to buffer Image 16// - Not when creating on the fly preview 17// - When creating multiple preview files 18// - When preview base has to be created from content 19 20// Translates previewTypes to Imaging functions. Returns image interface 21func Preview(oimg *image.Image, opt PreviewOptions) (img image.Image, err error) { 22 23 if err != nil { 24 return img, err 25 } 26 27 if opt.Method == "resize" { 28 img = imaging.Resize(*oimg, opt.Width, opt.Height, imaging.Box) 29 } else { 30 img = imaging.Thumbnail(*oimg, opt.Width, opt.Height, imaging.Linear) 31 } 32 33 return // img and err are implicit 34} 35 36// Path of Preview file 37// - Used to check if exists, uploading, redirecting 38func PreviewPath(objname string, ptype string) (path string) { 39 return "" 40} 41 42func Generate() { 43 44}