Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/image/webp: Missing RIFF Chunk Header #30712

Closed
yaput opened this issue Mar 10, 2019 · 4 comments
Closed

x/image/webp: Missing RIFF Chunk Header #30712

yaput opened this issue Mar 10, 2019 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@yaput
Copy link

yaput commented Mar 10, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12 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
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bluelogic2/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bluelogic2/Desktop/Antonius/Work/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dq/_cn_jltj0058y0n7ds3_65t80000gn/T/go-build699185468=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

	imgData, err := os.Open(filename)
	if err != nil {
		log.Printf("%+v", err)
		return
	}
	image, err := webp.Decode(imgData)
	if err != nil {
		log.Printf("WEBP DECODE : %+v", err)
		return
	}
        ....

What did you expect to see?

Decoded webp

What did you see instead?

riff: missing RIFF chunk header

@yaput yaput changed the title Missing RIFF Chunk Header x/image/webp: Missing RIFF Chunk Header Mar 10, 2019
@gopherbot gopherbot added this to the Unreleased milestone Mar 10, 2019
@ALTree
Copy link
Member

ALTree commented Mar 10, 2019

Thanks for reporting this.

Can you attach (or give a link to) the image that trigger the issue? It also would be nice to have a complete, runnable reproducer (that includes a main function).

@ALTree ALTree added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 10, 2019
@yaput
Copy link
Author

yaput commented Mar 10, 2019

Thanks for responding this, here is the image

and for main function

func main(){
	imgData, err := os.Open("343b0a37201220b80909cbebebe8ef21.webp")
	if err != nil {
		log.Printf("%+v", err)
		return
	}
	image, err := webp.Decode(imgData)
	if err != nil {
		log.Printf("WEBP DECODE : %+v", err)
		return
	}
	newImage := resize.Resize(300, 0, image, resize.Lanczos3)
	newFilename := "resized_image/" + strings.Replace(filename, "webp", "jpg", -1)
	os.Create(newFilename)
	newImg, _ := os.Open(newFilename)
	defer newImg.Close()
	// Encode uses a Writer, use a Buffer if you need the raw []byte
	err = jpeg.Encode(newImg, newImage, nil)
	if err != nil {
		log.Printf("%+v", err)
		return
	}       
         
}

Maybe the function is not working, cause i change the format from webp to jpeg, but i can't find webp encoder function in webp package, so i just tried to save the resized image. Thanks a lot

@antong
Copy link
Contributor

antong commented Mar 11, 2019

@yaput , Can you double check that the file contents are what you think they are. I downloaded your file (sha1sum dafb30bfe35c7296052f9279d2368d4e92d509e0) and it decoded fine, without errors.

func main() {
        imgData, err := os.Open("343b0a37201220b80909cbebebe8ef21.webp")
        if err != nil {
                fmt.Println(err)
                return
        }
        image, err := webp.Decode(imgData)
        if err != nil {
                fmt.Println(err)
                return
        }
        fmt.Println(image.Bounds())
        // Output:
        // (0,0)-(400,156)
}

@yaput
Copy link
Author

yaput commented Mar 13, 2019

Hi @antong , found something, it is not in the webp package, but maybe i did something wrong when downloaded the image from url with golang. After i tried to download the image from browser, it works. Maybe i will find another way around to store the image before resizing it. Thanks!

@yaput yaput closed this as completed Mar 13, 2019
@golang golang locked and limited conversation to collaborators Mar 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants