diff --git a/cmd/webp-manual-test/main.go b/cmd/webp-manual-test/main.go index c041e21..296c763 100644 --- a/cmd/webp-manual-test/main.go +++ b/cmd/webp-manual-test/main.go @@ -38,13 +38,9 @@ var ( func main() { flag.Parse() - if *dwebp == "" { + if err := checkDwebp(); err != nil { flag.Usage() - log.Fatal("dwebp flag was not specified") - } - if _, err := os.Stat(*dwebp); err != nil { - flag.Usage() - log.Fatalf("could not find dwebp program at %q", *dwebp) + log.Fatal(err) } if *testdata == "" { flag.Usage() @@ -81,6 +77,25 @@ func main() { } } +func checkDwebp() error { + if *dwebp == "" { + return fmt.Errorf("dwebp flag was not specified") + } + if _, err := os.Stat(*dwebp); err != nil { + return fmt.Errorf("could not find dwebp program at %q", *dwebp) + } + b, err := exec.Command(*dwebp, "-version").Output() + if err != nil { + return fmt.Errorf("could not determine the dwebp program version for %q: %v", *dwebp, err) + } + switch s := string(bytes.TrimSpace(b)); s { + case "0.4.0", "0.4.1", "0.4.2": + return fmt.Errorf("the dwebp program version %q for %q has a known bug "+ + "(https://bugs.chromium.org/p/webp/issues/detail?id=239). Please use a newer version.", s, *dwebp) + } + return nil +} + // test tests a single WEBP image. func test(name string) error { filename := filepath.Join(*testdata, name)