Description
What version of Go are you using (go version
)?
$ go version go version go1.16.3 windows/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\***\AppData\Local\go-build set GOENV=C:\Users\***\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\***\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\***\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.16.3 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=NUL set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\***\AppData\Local\Temp\go-build2404133136=/tmp/go-build -gno-record-gcc-switches
What did you do?
I work with a web platform, where multiple users can post their content, including images. We're moving from legacy solution based on PHP and re-implementing it in Go. One of the functionality required for a platform is resizing/cropping images. We used github.com/disintegration/imaging
for that and encountered this problem with that library originally. What happens is that for some particular jpeg
images, there is an error when you try to decode it using standard library.
Please note, that Firefox/Chrome/etc browsers open and display that image correctly, as well as imagick
(part of legacy solution) does resize/cropping of it without any problems. With image/jpeg
I'm getting unexpected EOF
when trying to decode an image.
Here is a sample code to reproduce an error:
package main
import (
"image"
_ "image/jpeg"
"os"
)
func main() {
f, err := os.Open("1.jpg")
if err != nil {
panic(err)
}
defer f.Close()
_, _, err = image.Decode(f)
if err != nil {
panic(err)
}
}
Output:
panic: unexpected EOF
...
Archived image:
1.zip
What did you expect to see?
No panic.
What did you see instead?
Panic.