mirror of
https://github.com/talgo-cloud/talgo-libwebp.git
synced 2026-03-08 23:18:13 -07:00
Fork and add module
The upstream harukasan/go-libwebp hasn't been updated in almost three years, so we're officially forking this into tidbyt/go-libwebp and making it a Go module.
This commit is contained in:
parent
7718986fb5
commit
dd1cead28d
12 changed files with 29 additions and 133 deletions
|
|
@ -10,29 +10,24 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetExFilePath returns the path of specified example file.
|
||||
func GetExFilePath(name string) string {
|
||||
for _, gopath := range strings.Split(os.Getenv("GOPATH"), ":") {
|
||||
path := filepath.Join(gopath, "src/github.com/harukasan/go-libwebp/examples/images", name)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return path
|
||||
}
|
||||
path := filepath.Join("../examples/images", name)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return path
|
||||
}
|
||||
panic(fmt.Errorf("%v does not exist in any directory which contains in $GOPATH", name))
|
||||
panic(fmt.Errorf("%v does not exist", path))
|
||||
}
|
||||
|
||||
// GetOutFilePath returns the path of specified out file.
|
||||
func GetOutFilePath(name string) string {
|
||||
for _, gopath := range strings.Split(os.Getenv("GOPATH"), ":") {
|
||||
path := filepath.Join(gopath, "src/github.com/harukasan/go-libwebp/examples/out")
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return filepath.Join(path, name)
|
||||
}
|
||||
path := "../examples/out"
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return filepath.Join(path, name)
|
||||
}
|
||||
panic(fmt.Errorf("out directory does not exist in any directory which contains in $GOPATH"))
|
||||
panic(fmt.Errorf("out directory does not exist"))
|
||||
}
|
||||
|
||||
// OpenFile opens specified example file
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
package util_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/harukasan/go-libwebp/test/util"
|
||||
)
|
||||
|
||||
var PNGFiles = []string{
|
||||
"butterfly.png",
|
||||
"cosmos.png",
|
||||
"fizyplankton.png",
|
||||
"kinkaku.png",
|
||||
"yellow-rose-3.png",
|
||||
}
|
||||
|
||||
var WebPFiles = []string{
|
||||
"butterfly.webp",
|
||||
"cosmos.webp",
|
||||
"fizyplankton.webp",
|
||||
"kinkaku.webp",
|
||||
"yellow-rose-3.webp",
|
||||
}
|
||||
|
||||
func TestOpenFile(t *testing.T) {
|
||||
for _, file := range PNGFiles {
|
||||
util.OpenFile(file)
|
||||
}
|
||||
for _, file := range WebPFiles {
|
||||
util.OpenFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadFile(t *testing.T) {
|
||||
for _, file := range PNGFiles {
|
||||
util.ReadFile(file)
|
||||
}
|
||||
for _, file := range WebPFiles {
|
||||
util.ReadFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateFile(t *testing.T) {
|
||||
f := util.CreateFile("util_test")
|
||||
f.Write([]byte{'o', 'k'})
|
||||
f.Close()
|
||||
}
|
||||
|
||||
func TestReadWritePNG(t *testing.T) {
|
||||
for _, file := range PNGFiles {
|
||||
png := util.ReadPNG(file)
|
||||
util.WritePNG(png, "util_test_"+file)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue