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.