diff options
| author | Antonia Rescribe <antonia@rescribe.xyz> | 2021-12-20 12:06:30 +0000 | 
|---|---|---|
| committer | Nick White <git@njw.name> | 2021-12-20 12:27:56 +0000 | 
| commit | 2e3bef288256fe25f982b9adeaacd2930cccd21e (patch) | |
| tree | 9b7612e82c2ff3c5b4885a55d0d2ce819ff10fc4 /internal/pipeline | |
| parent | 3e953e66d02416270356d0d7d3b6ea2df0260c77 (diff) | |
fixed -png flag and changed rescribe tool to save binarized png in separate folder
Diffstat (limited to 'internal/pipeline')
| -rw-r--r-- | internal/pipeline/get.go | 24 | 
1 files changed, 19 insertions, 5 deletions
| 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) | 
