forked from jason/cpolis
Implement banner images in a more standard way
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
@ -43,20 +42,3 @@ func SaveImage(src io.Reader, maxHeight, maxWidth int, path string) (string, err
|
||||
|
||||
return filename, nil
|
||||
}
|
||||
|
||||
func ServeBase64Image(c *Config, filename string) (string, error) {
|
||||
file := c.PicsDir + "/" + filename
|
||||
|
||||
img, err := os.Open(file)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error opening file %v: %v", file, err)
|
||||
}
|
||||
defer img.Close()
|
||||
|
||||
imgBytes, err := io.ReadAll(img)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error turning %v into bytes: %v", file, err)
|
||||
}
|
||||
|
||||
return base64.StdEncoding.EncodeToString(imgBytes), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user