summaryrefslogtreecommitdiff
path: root/cmd/rescribe
diff options
context:
space:
mode:
authorAntonia Rescribe <antonia@rescribe.xyz>2021-12-20 12:06:30 +0000
committerNick White <git@njw.name>2021-12-20 12:27:56 +0000
commit2e3bef288256fe25f982b9adeaacd2930cccd21e (patch)
tree9b7612e82c2ff3c5b4885a55d0d2ce819ff10fc4 /cmd/rescribe
parent3e953e66d02416270356d0d7d3b6ea2df0260c77 (diff)
fixed -png flag and changed rescribe tool to save binarized png in separate folder
Diffstat (limited to 'cmd/rescribe')
-rw-r--r--cmd/rescribe/gui.go4
-rw-r--r--cmd/rescribe/main.go21
2 files changed, 23 insertions, 2 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go
index 5e9e1dc..36d9b3a 100644
--- a/cmd/rescribe/gui.go
+++ b/cmd/rescribe/gui.go
@@ -99,6 +99,8 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir
myApp := app.New()
myWindow := myApp.NewWindow("Rescribe OCR")
+ myWindow.Resize(fyne.NewSize(800, 400))
+
var gobtn *widget.Button
dir := widget.NewEntry()
@@ -126,7 +128,7 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir
logarea.Disable()
// TODO: have the button be pressed if enter is pressed
- gobtn = widget.NewButtonWithIcon("Process OCR", theme.UploadIcon(), func() {
+ gobtn = widget.NewButtonWithIcon("Start OCR", theme.UploadIcon(), func() {
if dir.Text == "" {
return
}
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go
index 59d8166..89eb590 100644
--- a/cmd/rescribe/main.go
+++ b/cmd/rescribe/main.go
@@ -471,7 +471,21 @@ func startProcess(logger log.Logger, tessCommand string, bookdir string, booknam
if err != nil {
log.Fatalf("Error moving hocr %s to hocr directory: %v", v, err)
}
+
+ pngname := strings.Replace(v, ".hocr", ".png", 1)
+ err = os.MkdirAll(filepath.Join(savedir, "png"), 0755)
+ if err != nil {
+ log.Fatalf("Error creating hocr directory: %v", err)
+ }
+
+ err = os.Rename(pngname, filepath.Join(savedir, "png", filepath.Base(pngname)))
+ if err != nil {
+ log.Fatalf("Error moving png %s to hocr directory: %v", pngname, err)
+ }
+
}
+
+
// For simplicity, remove .binarised.pdf and rename .colour.pdf to .pdf
_ = os.Remove(filepath.Join(savedir, bookname+".binarised.pdf"))
@@ -531,10 +545,15 @@ func uploadbook(dir string, name string, conn Pipeliner) error {
}
func downloadbook(dir string, name string, conn Pipeliner) error {
- err := pipeline.DownloadBestPages(dir, name, conn, false)
+ err := pipeline.DownloadBestPages(dir, name, conn)
if err != nil {
return fmt.Errorf("Error downloading best pages: %v", err)
}
+
+ err1 := pipeline.DownloadBestPngs(dir, name, conn)
+ if err1 != nil {
+ return fmt.Errorf("Error downloading best pngs: %v", err)
+ }
err = pipeline.DownloadPdfs(dir, name, conn)
if err != nil {