chai2010 / chai2010/webp

undefined问题

Open
#71 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
723
Forks
113
PR merge metrics
No merged PRs in 30d

Description

按照文档的方式写了示例代码:
package main

import (
"bytes"
"fmt"
"io/ioutil"
"log"

"github.com/chai2010/webp"
)

func main() {
var buf bytes.Buffer
var width, height int
var data []byte
var err error

// Load file data
if data, err = ioutil.ReadFile("./testdata/1_webp_ll.webp"); err != nil {
log.Println(err)
}

// GetInfo
if width, height, _, err = webp.GetInfo(data); err != nil {
log.Println(err)
}
fmt.Printf("width = %d, height = %d\n", width, height)

// GetMetadata
if metadata, err := webp.GetMetadata(data, "ICCP"); err != nil {
fmt.Printf("Metadata: err = %v\n", err)
} else {
fmt.Printf("Metadata: %s\n", string(metadata))
}

// Decode webp
m, err := webp.Decode(bytes.NewReader(data))
if err != nil {
log.Println(err)
}

// Encode lossless webp
if err = webp.Encode(&buf, m, &webp.Options{Lossless: true}); err != nil {
log.Println(err)
}
if err = ioutil.WriteFile("output.webp", buf.Bytes(), 0666); err != nil {
log.Println(err)
}

fmt.Println("Save output.webp ok")
}

go.mod中:
module test_prj

go 1.20

require (
github.com/chai2010/webp v1.1.1
)

go run 的时候报错:
# github.com/chai2010/webp
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:22:9: undefined: webpGetInfo
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:26:20: undefined: webpDecodeGray
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:39:20: undefined: webpDecodeRGB
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:52:20: undefined: webpDecodeRGBA
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:68:14: undefined: webpDecodeGrayToSize
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:82:14: undefined: webpDecodeRGBToSize
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:96:14: undefined: webpDecodeRGBAToSize
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:109:7: undefined: toGrayImage
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:110:14: undefined: webpEncodeGray
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:119:14: undefined: webpEncodeRGB
/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:119:14: too many errors

golang版本:
go version go1.20.14 linux/amd64

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.