mirror of
https://github.com/disintegration/imaging.git
synced 2025-12-24 12:58:00 +08:00
Add golden tests for Thumbnail
This commit is contained in:
@@ -630,6 +630,24 @@ func TestThumbnail(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestThumbnailGolden(t *testing.T) {
|
||||
for name, filter := range map[string]ResampleFilter{
|
||||
"out_thumbnail_nearest.png": NearestNeighbor,
|
||||
"out_thumbnail_linear.png": Linear,
|
||||
"out_thumbnail_catrom.png": CatmullRom,
|
||||
"out_thumbnail_lanczos.png": Lanczos,
|
||||
} {
|
||||
got := Thumbnail(testdataBranchesPNG, 150, 100, filter)
|
||||
want, err := Open("testdata/" + name)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open image: %v", err)
|
||||
}
|
||||
if !compareNRGBA(got, toNRGBA(want), 0) {
|
||||
t.Fatalf("resulting image differs from golden: %s", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkResize(b *testing.B) {
|
||||
for _, dir := range []string{"Down", "Up"} {
|
||||
for _, filter := range []string{"NearestNeighbor", "Linear", "CatmullRom", "Lanczos"} {
|
||||
|
||||
BIN
testdata/out_thumbnail_catrom.png
vendored
Normal file
BIN
testdata/out_thumbnail_catrom.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
BIN
testdata/out_thumbnail_lanczos.png
vendored
Normal file
BIN
testdata/out_thumbnail_lanczos.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
BIN
testdata/out_thumbnail_linear.png
vendored
Normal file
BIN
testdata/out_thumbnail_linear.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
BIN
testdata/out_thumbnail_nearest.png
vendored
Normal file
BIN
testdata/out_thumbnail_nearest.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Reference in New Issue
Block a user