From 2e3bef288256fe25f982b9adeaacd2930cccd21e Mon Sep 17 00:00:00 2001 From: Antonia Rescribe Date: Mon, 20 Dec 2021 12:06:30 +0000 Subject: fixed -png flag and changed rescribe tool to save binarized png in separate folder --- internal/pipeline/get.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'internal') diff --git a/internal/pipeline/get.go b/internal/pipeline/get.go index 960c8f7..2559857 100644 --- a/internal/pipeline/get.go +++ b/internal/pipeline/get.go @@ -12,7 +12,7 @@ import ( "strings" ) -func DownloadBestPages(dir string, name string, conn Downloader, pluspngs bool) error { +func DownloadBestPages(dir string, name string, conn Downloader) error { key := filepath.Join(name, "best") fn := filepath.Join(dir, "best") err := conn.Download(conn.WIPStorageId(), key, fn) @@ -35,12 +35,25 @@ func DownloadBestPages(dir string, name string, conn Downloader, pluspngs bool) return fmt.Errorf("Failed to download file %s: %v", key, err) } } + return nil +} - if !pluspngs { - return nil - } +func DownloadBestPngs(dir string, name string, conn Downloader) error { - s = bufio.NewScanner(f) + key := filepath.Join(name, "best") + fn := filepath.Join(dir, "best") + err := conn.Download(conn.WIPStorageId(), key, fn) + if err != nil { + return fmt.Errorf("Failed to download 'best' file: %v", err) + } + f, err := os.Open(fn) + if err != nil { + return fmt.Errorf("Failed to open best file: %v", err) + } + defer f.Close() + + + s := bufio.NewScanner(f) for s.Scan() { imgname := strings.Replace(s.Text(), ".hocr", ".png", 1) key = filepath.Join(name, imgname) @@ -54,6 +67,7 @@ func DownloadBestPages(dir string, name string, conn Downloader, pluspngs bool) return nil } + func DownloadPdfs(dir string, name string, conn Downloader) error { for _, suffix := range []string{".colour.pdf", ".binarised.pdf"} { key := filepath.Join(name, name+suffix) -- cgit v1.2.1-24-ge1ad