Implement banner images in a more standard way

This commit is contained in:
2024-10-29 16:36:40 +01:00
parent be829e662b
commit 20a12c6299
6 changed files with 40 additions and 63 deletions

View File

@ -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
}