Skip to content

Commit

Permalink
Fix return
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti committed Feb 15, 2024
1 parent 35ad5a1 commit eca5a23
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package image

import (
"bytes"
"encoding/base64"
"fmt"
"image"
"image/color"
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit eca5a23

Please sign in to comment.