Open wzhsh90 opened 3 years ago
step1、 dstImage := imaging.Resize(srcImage, 210, 250, imaging.Lanczos)
step2、 I need dstImage byte data ,how to do?
Once you've performed all your operations on the image object, dump the bytes out.
// assumes PNG to JPG, no exception handling, just raw example
// load in a PNG
src, _ := imaging.Open("sampleimage.png")
// resize it
dst := imaging.Resize(src, 250, 0, imaging.Lanczos)
// get a bytes buffer container
buf := new(bytes.Buffer)
// use jpg encode ( assuming JPG ) and push the bytes out to the buffer
jpeg.Encode(buf, dst, nil)
// dump out the bytes to a file
ioutil.WriteFile("sampleimageout.jpg", buf.Bytes(), 0644)
ok , thank you.
---Original--- From: "George @.> Date: Sat, Apr 24, 2021 22:45 PM To: @.>; Cc: @.**@.>; Subject: Re: [disintegration/imaging] how to get image byte data (#141)
Once you've performed all your operations on the image object, dump the bytes out.
src, _ := imaging.Open("sampleimage.png") dst := imaging.Resize(src, 250, 0, imaging.Lanczos) buf := new(bytes.Buffer) jpeg.Encode(buf, dst, nil) ioutil.WriteFile("sampleimageout.jpg", buf.Bytes(), 0644)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
step1、 dstImage := imaging.Resize(srcImage, 210, 250, imaging.Lanczos)
step2、 I need dstImage byte data ,how to do?