From d58cb7f0009966781a907ee7fb2ab8bd439f88ff Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 23 Nov 2023 20:28:40 -0300 Subject: [PATCH] embed logo in the binary. --- render_image.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/render_image.go b/render_image.go index 671d4df..8b7c685 100644 --- a/render_image.go +++ b/render_image.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "embed" "fmt" @@ -36,6 +37,9 @@ var ( //go:embed fonts/* var fonts embed.FS +//go:embed static/logo.png +var logo []byte + func renderImage(w http.ResponseWriter, r *http.Request) { fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent")) @@ -186,12 +190,8 @@ func drawImage(lines []string, ttf *truetype.Font, style Style) (image.Image, er img.DrawString(line, float64(20+paddingLeft), y) // Draw the line at the calculated Y position } - // Create the stamp image - stampImg, err := gg.LoadPNG("static/logo.png") - if err != nil { - return nil, err - } - + // create the stamp image + stampImg, _ := png.Decode(bytes.NewBuffer(logo)) stampWidth := stampImg.Bounds().Dx() stampHeight := stampImg.Bounds().Dy()