Pleae help in converting an image that resides at url path on aws bucket to base64 encoded string.
Try this:
b64 “encoding/base64” -> https://golang.org/pkg/encoding/base64/
In this example I’m already decreasing the image size
file, _, err := req.FormFile("image")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer file.Close()
img, _, err := image.Decode(file)
m := resize.Resize(135, 115, img, resize.Lanczos3)
buf := new(bytes.Buffer)
err = jpeg.Encode(buf, m, &jpeg.Options{35})
imageBit := buf.Bytes()
/*Defining the new image size*/
photoBase64 := b64.StdEncoding.EncodeToString([]byte(imageBit))
fmt.Println("Photo Base64.............................:" + fotoBase64)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.