diff options
-rw-r--r-- | cmd/rescribe/main.go | 4 | ||||
-rw-r--r-- | internal/pipeline/pipeline.go | 1 | ||||
-rw-r--r-- | internal/pipeline/util.go | 16 | ||||
-rw-r--r-- | internal/pipeline/util_windows.go | 16 |
4 files changed, 36 insertions, 1 deletions
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go index 41dc83c..7db5e3e 100644 --- a/cmd/rescribe/main.go +++ b/cmd/rescribe/main.go @@ -428,7 +428,9 @@ func rmIfNotImage(f string) error { } func startProcess(ctx context.Context, logger log.Logger, tessCommand string, bookdir string, bookname string, trainingName string, savedir string, tessdir string) error { - _, err := exec.Command(tessCommand, "--help").Output() + cmd := exec.Command(tessCommand, "--help") + pipeline.HideCmd(cmd) + _, err := cmd.Output() if err != nil { errmsg := "Error, Can't run Tesseract\n" errmsg += "Ensure that Tesseract is installed and available, or don't use the -systess flag.\n" diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index b4a9d92..639bba1 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -310,6 +310,7 @@ func Ocr(training string, tesscmd string) func(context.Context, chan string, cha logger.Println("OCRing", path) name := strings.Replace(path, ".png", "", 1) cmd := exec.Command(tesscmd, "-l", training, path, name, "-c", "tessedit_create_hocr=1", "-c", "hocr_font_info=0") + HideCmd(cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout cmd.Stderr = &stderr diff --git a/internal/pipeline/util.go b/internal/pipeline/util.go new file mode 100644 index 0000000..092a9ee --- /dev/null +++ b/internal/pipeline/util.go @@ -0,0 +1,16 @@ +// Copyright 2022 Nick White. +// Use of this source code is governed by the GPLv3 +// license that can be found in the LICENSE file. + +// +build !windows + +package pipeline + +import ( + "os/exec" +) + +// HideCmd adds a flag to hide any console window from being +// displayed, if necessary for the platform +func HideCmd(cmd *exec.Cmd) { +} diff --git a/internal/pipeline/util_windows.go b/internal/pipeline/util_windows.go new file mode 100644 index 0000000..08c321e --- /dev/null +++ b/internal/pipeline/util_windows.go @@ -0,0 +1,16 @@ +// Copyright 2022 Nick White. +// Use of this source code is governed by the GPLv3 +// license that can be found in the LICENSE file. + +package pipeline + +import ( + "os/exec" + "syscall" +) + +// HideCmd adds a flag to hide any console window from being +// displayed, if necessary for the platform +func HideCmd(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} +} |