|
@@ -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"} {
|