-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed
Labels
Milestone
Description
Q1. go version go1.6 linux/amd64
Q2.
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/gopath"
GORACE=""
GOROOT="/root/go"
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
Q3. Decoding and re-encoding image produces wrong image.
Steps to reproduce:
a. wget -O test.jpg https://cloud.githubusercontent.com/assets/203454/13348844/ebd58db6-dc86-11e5-91c2-59daeddf50c7.jpg
b. go run file.go
c. open test.jpg and out.jpg in any image viewer
package main
import (
"bytes"
"os"
"log"
"image"
"image/jpeg"
"io/ioutil"
)
func main() {
reader, err := os.Open("test.jpg")
defer reader.Close()
m, _, err := image.Decode(reader)
if err != nil {
log.Fatal(err)
}
buf := new(bytes.Buffer)
jpeg.Encode(buf, m, &jpeg.Options{Quality: 85})
ioutil.WriteFile("out.jpg", buf.Bytes(), 0644)
}
Q4. I expected to see image visually similar to original
Q5. I got image visually different from the original.

