image - Golang io.Reader issue with jpeg.Decode returning EOF -


i trying take multipart.file io.reader , decode jpeg covert thumbnail using github.com/disintegration/imaging's library. know in advance data going jpeg. when send multipart.file convertimagetothumbnail function , returns unexpected eof every time. doing wrong?

package images  import (     "github.com/disintegration/imaging"     "image"     "image/jpeg"     "mime/multipart" )  func convertimagetothumbnail(pic multipart.file) (image.image, error) {     pic.seek(0,0) // solution seek beginning of file     img,err := jpeg.decode(pic)     if err != nil {         return nil, err     }     thumb := imaging.thumbnail(img, 100, 100, imaging.catmullrom)      return thumb, nil }   pic, header, err := r.formfile("avatar")  // check error defer pic.close() 

pic.seek(0,0) before decode fixed issue.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -