mirror of https://github.com/perkeep/perkeep.git
Merge "app/scanningcabinet: Fix scancab pdf extraction"
This commit is contained in:
commit
640fd08296
|
@ -147,7 +147,7 @@ func uploadOne(filename string) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Uploading %v ...\n", filename)
|
fmt.Printf("Uploading %v ...\n", filename)
|
||||||
if !strings.HasSuffix(filename, ".pdf") {
|
if !strings.HasSuffix(strings.ToLower(filename), ".pdf") {
|
||||||
if err := uploadFile(filename); err != nil {
|
if err := uploadFile(filename); err != nil {
|
||||||
log.Fatalf("Could not upload file %v: %v", filename, err)
|
log.Fatalf("Could not upload file %v: %v", filename, err)
|
||||||
}
|
}
|
||||||
|
@ -176,10 +176,10 @@ func uploadOne(filename string) {
|
||||||
}()
|
}()
|
||||||
for i := 0; i < cnt; i++ {
|
for i := 0; i < cnt; i++ {
|
||||||
fmt.Printf(" page %04d of %04d\n", i+1, cnt)
|
fmt.Printf(" page %04d of %04d\n", i+1, cnt)
|
||||||
converted := path.Join(tmpDir, fmt.Sprintf("page-$04d.%v", i+1, ext))
|
converted := path.Join(tmpDir, fmt.Sprintf("page-%04d.%v", i+1, ext))
|
||||||
args = append(args, fmt.Sprintf("%v[%d]", filename, i), converted)
|
pageArgs := append(args, fmt.Sprintf("%v[%d]", filename, i), converted)
|
||||||
// TODO(mpl): how about using pdftk instead of convert, to get contents without rasterizing them ?
|
// TODO(mpl): how about using pdftk instead of convert, to get contents without rasterizing them ?
|
||||||
cmd := exec.Command("convert", args...)
|
cmd := exec.Command("convert", pageArgs...)
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not convert page %d of %v: %v, %v", i, filename, err, string(out))
|
log.Fatalf("could not convert page %d of %v: %v, %v", i, filename, err, string(out))
|
||||||
|
|
Loading…
Reference in New Issue