mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package thumb
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
|
)
|
|
|
|
func TestFileInfo(t *testing.T) {
|
|
t.Run("Jpeg", func(t *testing.T) {
|
|
fileName := fs.Abs("./testdata/example.jpg")
|
|
|
|
if fileInfo, err := FileInfo(fileName); err != nil {
|
|
t.Fatal(err)
|
|
} else {
|
|
assert.Equal(t, 750, fileInfo.Width)
|
|
assert.Equal(t, 500, fileInfo.Height)
|
|
}
|
|
})
|
|
t.Run("BrokenJpeg", func(t *testing.T) {
|
|
fileName := fs.Abs("./testdata/broken.jpg")
|
|
|
|
if fileInfo, err := FileInfo(fileName); err != nil {
|
|
t.Fatal(err)
|
|
} else {
|
|
assert.Equal(t, 705, fileInfo.Width)
|
|
assert.Equal(t, 725, fileInfo.Height)
|
|
}
|
|
})
|
|
t.Run("Png", func(t *testing.T) {
|
|
fileName := fs.Abs("./testdata/example.png")
|
|
|
|
if fileInfo, err := FileInfo(fileName); err != nil {
|
|
t.Fatal(err)
|
|
} else {
|
|
assert.Equal(t, 100, fileInfo.Width)
|
|
assert.Equal(t, 67, fileInfo.Height)
|
|
}
|
|
})
|
|
t.Run("Bmp", func(t *testing.T) {
|
|
fileName := fs.Abs("./testdata/example.bmp")
|
|
|
|
if fileInfo, err := FileInfo(fileName); err != nil {
|
|
t.Fatal(err)
|
|
} else {
|
|
assert.Equal(t, 100, fileInfo.Width)
|
|
assert.Equal(t, 67, fileInfo.Height)
|
|
}
|
|
})
|
|
t.Run("Gif", func(t *testing.T) {
|
|
fileName := fs.Abs("./testdata/example.bmp")
|
|
|
|
if fileInfo, err := FileInfo(fileName); err != nil {
|
|
t.Fatal(err)
|
|
} else {
|
|
assert.Equal(t, 100, fileInfo.Width)
|
|
assert.Equal(t, 67, fileInfo.Height)
|
|
}
|
|
})
|
|
}
|