Hi am downloading a picture from a gc Bucket after download i end up with a [] trying to decode it in to the picture so i can manipulated it. but i keep getting a nil value. please help here is my code
//read object from bucket
rc, err := bkt.Object("1090873.jpeg").NewReader(ctx)
if err != nil {
fmt.Println("Error getting image from bucket")
}
data, err := ioutil.ReadAll(rc)
if err != nil {
fmt.Pringln("Error reading rc")
}
// decode []byte in to workable image
img, _, _ := image.Decode(bytes.NewReader(data))
if img == nil {
fmt.Println("Your don't have an image body")
}
i have tried variations of this func but not sure if am using this right obviously not since is not working.
img, _, _ := image.Decode(bytes.NewReader(data))
am sure i have data is not nill cause i can print the value of the []byte array to the console just don’t know how to turn it in to an image. My next line of code would be:
// Resize the cropped image to width = 500px preserving the aspect ratio.
img = imaging.Resize(src, 500, 0, imaging.Lanczos)