go
go copied to clipboard
image/png: DecodeConfig gives incorrect result for paletted images with transparency
The color model returned from png.DecodeConfig is different from the one returned from png.Decode, because it incorrectly omits the alpha channel data.
What version of Go are you using (go version
)?
$ go version go version go1.19 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
go env
Output
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/depp/Library/Caches/go-build" GOENV="/Users/depp/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/depp/Projects/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/depp/Projects/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/Cellar/go/1.19/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.19/libexec/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.19" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1l/g8_2q7j95rndy_wpjnd5b1h00000gn/T/go-build1338501950=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
See go.dev/play snippet
When run, prints
Color 0 (png.DecodeConfig): {0 0 0 255} Color 0 (png.Decode): {0 0 0 0} Program exited.
What did you expect to see?
Same color model, no matter whether I used DecodeConfig or Decode
What did you see instead?
Palette entry 0 has alpha = 255 (incorrect) if returned by DecodeConfig, alpha = 0 (correct) if returned by Decode.
CC @nigeltao
Change https://go.dev/cl/424917 mentions this issue: image/png: have DecodeConfig read tRNS chunks