1
0
mirror of https://github.com/fumiama/imgsz.git synced 2026-06-12 06:00:28 +08:00

🎉 完成

This commit is contained in:
fumiama
2022-01-08 15:09:05 +08:00
parent d016c6e69d
commit fd0b2eae31
14 changed files with 1181 additions and 0 deletions

60
image_test.go Normal file
View File

@@ -0,0 +1,60 @@
package imgsz
import (
"os"
"testing"
)
func TestSizes(t *testing.T) {
f, err := os.Open("testdata/test.webp")
if err != nil {
t.Fatal(err)
}
sz, n, err := DecodeSize(f)
if err != nil {
t.Fatal(err)
}
if sz.Width != 3507 || sz.Height != 2480 || n != "webp" {
t.Fatal(sz, n)
}
f.Close()
f, err = os.Open("testdata/test.jpg")
if err != nil {
t.Fatal(err)
}
sz, n, err = DecodeSize(f)
if err != nil {
t.Fatal(err)
}
if sz.Width != 858 || sz.Height != 1126 || n != "jpeg" {
t.Fatal(sz, n)
}
f.Close()
f, err = os.Open("testdata/test.png")
if err != nil {
t.Fatal(err)
}
sz, n, err = DecodeSize(f)
if err != nil {
t.Fatal(err)
}
if sz.Width != 670 || sz.Height != 717 || n != "png" {
t.Fatal(sz, n)
}
f.Close()
f, err = os.Open("testdata/test.gif")
if err != nil {
t.Fatal(err)
}
sz, n, err = DecodeSize(f)
if err != nil {
t.Fatal(err)
}
if sz.Width != 184 || sz.Height != 166 || n != "gif" {
t.Fatal(sz, n)
}
f.Close()
}