From eca5a238383d5a7c192cfca790a72cb8396f1c01 Mon Sep 17 00:00:00 2001 From: Vegard Stikbakke Date: Thu, 15 Feb 2024 21:27:47 +0100 Subject: [PATCH] Fix return --- image/image.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/image/image.go b/image/image.go index 14a2f1a..035cc19 100644 --- a/image/image.go +++ b/image/image.go @@ -2,7 +2,6 @@ package image import ( "bytes" - "encoding/base64" "fmt" "image" "image/color" @@ -13,11 +12,11 @@ import ( ) // AddBoxes adds bounding boxes to the base64 encoded image and returns a new base64 encoded image -func AddBoxes(imageBytes []byte, boxes []box.Box) (string, error) { +func AddBoxes(imageBytes []byte, boxes []box.Box) ([]byte, error) { imgReader := bytes.NewReader(imageBytes) img, _, err := image.Decode(imgReader) if err != nil { - return "", fmt.Errorf("decode: %w", err) + return nil, fmt.Errorf("decode: %w", err) } // Create a new image for the output @@ -34,10 +33,9 @@ func AddBoxes(imageBytes []byte, boxes []box.Box) (string, error) { var buf bytes.Buffer err = png.Encode(&buf, outputImg) if err != nil { - return "", err + return nil, err } - - return base64.StdEncoding.EncodeToString(buf.Bytes()), nil + return buf.Bytes(), nil } // drawBox draws a single Box on the image