volcengine / volc-sdk-golang

Apache License 2.0
103 stars 50 forks source link

how assign image path? #16

Open weidalin opened 2 years ago

weidalin commented 2 years ago

return : 400 {"request_id":"2022111111241301021001804606D4E147","time_elapsed":"24.80752ms","code":50207,"message":"Image Decode Error: image format unsupported","data":null}

how edit " form.Add("image_base64", "") "

form.Add("image_base64", imgPath) or image_base64 = toBase64(imgPath) form.Add("image_base64", image_base64)?

weidalin commented 2 years ago

srcByte, err := ioutil.ReadFile(D:\\1.jpg) if err != nil { log.Fatal(err) }

image_base64 := base64.StdEncoding.EncodeToString(srcByte)
form := url.Values{}
form.Add("image_base64", image_base64)

resp, status, err := visual.DefaultInstance.GeneralSegment(form)
fmt.Println(status, err)
b, _ := json.Marshal(resp)

how to write byte[] b to image?