synOCR synOCR - GUI für OCRmyPDF

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Das ist eine Angelegenheit von ocrmypdf - nicht vergessen: synOCR ist nur eine GUI ;)
Aber man kann durchaus die "Aggressivität" der automatischen Drehung steuern. Das Zauberwort heißt --rotate-pages-threshold. Infos darüber findest du HIER. Leider wurde dein Dokument selbst mit einer aggressiven Einstellung von 1, bzw. 2 nicht wie gewünscht gedreht. Aber vielleicht ist das ein Anhaltspunkt für weitere Tests deinerseits (Feedback erwünscht).

PS: ich fahre sehr gut mit der Einstellung: --rotate-pages --rotate-pages-threshold 5
 
  • Like
Reaktionen: peterhoffmann

peterhoffmann

Benutzer
Sehr erfahren
Mitglied seit
17. Dez 2014
Beiträge
5.548
Punkte für Reaktionen
1.390
Punkte
234

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Derzeit in meinem Hauptprofil so:
--author xxx --jobs 4 --rotate-pages --rotate-pages-threshold 5 -dc --skip-text --clean-final -l deu --jbig2-lossy --optimize 3

Ich scanne in der Regel in schwarz/weiß und lege Wert auf möglichst kleine Dateien. Hier hilft --jbig2-lossy --optimize 3

Wen es interessiert, hier mal die ocrmypdf Hilfe (nicht alles mag in Verbindung mit synOCR und dem Dockerimage funktionieren):
Code:
ocrmypdf --help

usage: ocrmypdf [-h] [-l LANGUAGE] [--image-dpi DPI]
                [--output-type {pdfa,pdf,pdfa-1,pdfa-2,pdfa-3}]
                [--sidecar [FILE]] [--version] [-j N] [-q] [-v [VERBOSE]]
                [--title TITLE] [--author AUTHOR] [--subject SUBJECT]
                [--keywords KEYWORDS] [-r] [--remove-background] [-d] [-c]
                [-i] [--oversample DPI] [--remove-vectors] [--mask-barcodes]
                [--threshold] [-f] [-s] [--redo-ocr] [--skip-big MPixels]
                [-O {0,1,2,3}] [--jpeg-quality Q] [--png-quality Q]
                [--jbig2-lossy] [--max-image-mpixels MPixels]
                [--tesseract-config CFG] [--tesseract-pagesegmode PSM]
                [--tesseract-oem MODE] [--pdf-renderer {auto,hocr,sandwich}]
                [--tesseract-timeout SECONDS]
                [--rotate-pages-threshold CONFIDENCE]
                [--pdfa-image-compression {auto,jpeg,lossless}]
                [--user-words FILE] [--user-patterns FILE] [-k]
                [--flowchart FLOWCHART]
                input_pdf_or_image output_pdf

Generates a searchable PDF or PDF/A from a regular PDF.

OCRmyPDF rasterizes each page of the input PDF, optionally corrects page
rotation and performs image processing, runs the Tesseract OCR engine on the
image, and then creates a PDF from the OCR information.

positional arguments:
  input_pdf_or_image    PDF file containing the images to be OCRed (or '-' to
                        read from standard input)
  output_pdf            Output searchable PDF file (or '-' to write to
                        standard output). Existing files will be ovewritten.
                        If same as input file, the input file will be updated
                        only if processing is successful.

optional arguments:
  -h, --help            show this help message and exit
  -l LANGUAGE, --language LANGUAGE
                        Language(s) of the file to be OCRed (see tesseract
                        --list-langs for all language packs installed in your
                        system). Use -l eng+deu for multiple languages.
  --image-dpi DPI       For input image instead of PDF, use this DPI instead
                        of file's.
  --output-type {pdfa,pdf,pdfa-1,pdfa-2,pdfa-3}
                        Choose output type. 'pdfa' creates a PDF/A-2b
                        compliant file for long term archiving (default,
                        recommended) but may not suitable for users who want
                        their file altered as little as possible. 'pdfa' also
                        has problems with full Unicode text. 'pdf' attempts to
                        preserve file contents as much as possible. 'pdf-a1'
                        creates a PDF/A1-b file. 'pdf-a2' is equivalent to
                        'pdfa'. 'pdf-a3' creates a PDF/A3-b file.
  --sidecar [FILE]      Generate sidecar text files that contain the same text
                        recognized by Tesseract. This may be useful for
                        building a OCR text database. If FILE is omitted, the
                        sidecar file be named {output_file}.txt If FILE is set
                        to '-', the sidecar is written to stdout (a convenient
                        way to preview OCR quality). The output file and
                        sidecar may not both use stdout at the same time.
  --version             Print program version and exit

Job control options:
  -j N, --jobs N        Use up to N CPU cores simultaneously (default: use
                        all).
  -q, --quiet           Suppress INFO messages
  -v [VERBOSE], --verbose [VERBOSE]
                        Print more verbose messages for each additional
                        verbose level

Metadata options:
  Set output PDF/A metadata (default: copy input document's metadata)

  --title TITLE         Set document title (place multiple words in quotes)
  --author AUTHOR       Set document author
  --subject SUBJECT     Set document subject description
  --keywords KEYWORDS   Set document keywords

Image preprocessing options:
  Options to improve the quality of the final PDF and OCR

  -r, --rotate-pages    Automatically rotate pages based on detected text
                        orientation
  --remove-background   Attempt to remove background from gray or color pages,
                        setting it to white
  -d, --deskew          Deskew each page before performing OCR
  -c, --clean           Clean pages from scanning artifacts before performing
                        OCR, and send the cleaned page to OCR, but do not
                        include the cleaned page in the output
  -i, --clean-final     Clean page as above, and incorporate the cleaned image
                        in the final PDF. Might remove desired content.
  --oversample DPI      Oversample images to at least the specified DPI, to
                        improve OCR results slightly
  --remove-vectors      EXPERIMENTAL. Mask out any vector objects in the PDF
                        so that they will not be included in OCR. This can
                        eliminate false characters.
  --mask-barcodes       EXPERIMENTAL. Mask out any barcodes that appear in the
                        PDF so they are not considered during OCR. Barcodes
                        can introduce false characters into OCR.
  --threshold           EXPERIMENTAL. Threshold image to 1bpp before sending
                        it to Tesseract for OCR. Can improve OCR quality
                        compared to Tesseract's thresholder.

OCR options:
  Control how OCR is applied

  -f, --force-ocr       Rasterize any text or vector objects on each page,
                        apply OCR, and save the rastered output (this rewrites
                        the PDF)
  -s, --skip-text       Skip OCR on any pages that already contain text, but
                        include the page in final output; useful for PDFs that
                        contain a mix of images, text pages, and/or previously
                        OCRed pages
  --redo-ocr            Attempt to detect and remove the hidden OCR layer from
                        files that were previously OCRed with OCRmyPDF or
                        another program. Apply OCR to text found in raster
                        images. Existing visible text objects will not be
                        changed. If there is no existing OCR, OCR will be
                        added.
  --skip-big MPixels    Skip OCR on pages larger than the specified amount of
                        megapixels, but include skipped pages in final output

Optimization options:
  Control how the PDF is optimized after OCR

  -O {0,1,2,3}, --optimize {0,1,2,3}
                        Control how PDF is optimized after processing:0 - do
                        not optimize; 1 - do safe, lossless optimizations
                        (default); 2 - do some lossy optimizations; 3 - do
                        aggressive lossy optimizations (including lossy JBIG2)
  --jpeg-quality Q      Adjust JPEG quality level for JPEG optimization. 100
                        is best quality and largest output size; 1 is lowest
                        quality and smallest output; 0 uses the default.
  --png-quality Q       Adjust PNG quality level to use when quantizing PNGs.
                        Values have same meaning as with --jpeg-quality
  --jbig2-lossy         Enable JBIG2 lossy mode (better compression, not
                        suitable for some use cases - see documentation).

Advanced:
  Advanced options to control Tesseract's OCR behavior

  --max-image-mpixels MPixels
                        Set maximum number of pixels to unpack before treating
                        an image as a decompression bomb
  --tesseract-config CFG
                        Additional Tesseract configuration files -- see
                        documentation
  --tesseract-pagesegmode PSM
                        Set Tesseract page segmentation mode (see tesseract
                        --help)
  --tesseract-oem MODE  Set Tesseract 4.0 OCR engine mode: 0 - original
                        Tesseract only; 1 - neural nets LSTM only; 2 -
                        Tesseract + LSTM; 3 - default.
  --pdf-renderer {auto,hocr,sandwich}
                        Choose OCR PDF renderer - the default option is to let
                        OCRmyPDF choose. See documentation for discussion.
  --tesseract-timeout SECONDS
                        Give up on OCR after the timeout, but copy the
                        preprocessed page into the final output
  --rotate-pages-threshold CONFIDENCE
                        Only rotate pages when confidence is above this value
                        (arbitrary units reported by tesseract)
  --pdfa-image-compression {auto,jpeg,lossless}
                        Specify how to compress images in the output PDF/A.
                        'auto' lets OCRmyPDF decide. 'jpeg' changes all
                        grayscale and color images to JPEG compression.
                        'lossless' uses PNG-style lossless compression for all
                        images. Monochrome images are always compressed using
                        a lossless codec. Compression settings are applied to
                        all pages, including those for which OCR was skipped.
                        Not supported for --output-type=pdf ; that setting
                        preserves the original compression of all images.
  --user-words FILE     Specify the location of the Tesseract user words file.
                        This is a list of words Tesseract should consider
                        while performing OCR in addition to its standard
                        language dictionaries. This can improve OCR quality
                        especially for specialized and technical documents.
  --user-patterns FILE  Specify the location of the Tesseract user patterns
                        file.

Debugging:
  Arguments to help with troubleshooting and debugging

  -k, --keep-temporary-files
                        Keep temporary files (helpful for debugging)
  --flowchart FLOWCHART
                        Generate the pipeline execution flowchart

OCRmyPDF attempts to keep the output file at about the same size.  If a file
contains losslessly compressed images, and output file will be losslessly
compressed as well.

PDF is a page description file that attempts to preserve a layout exactly.
A PDF can contain vector objects (such as text or lines) and raster objects
(images).  A page might have multiple images.  OCRmyPDF is prepared to deal
with the wide variety of PDFs that exist in the wild.

When a PDF page contains text, OCRmyPDF assumes that the page has already
been OCRed or is a "born digital" page that should not be OCRed.  The default
behavior is to exit in this case without producing a file.  You can use the
option --skip-text to ignore pages with text, or --force-ocr to rasterize
all objects on the page and produce an image-only PDF as output.

    ocrmypdf --skip-text file_with_some_text_pages.pdf output.pdf

    ocrmypdf --force-ocr word_document.pdf output.pdf

If you are concerned about long-term archiving of PDFs, use the default option
--output-type pdfa which converts the PDF to a standardized PDF/A-2b.  This
converts images to sRGB colorspace, removes some features from the PDF such
as Javascript or forms. If you want to minimize the number of changes made to
your PDF, use --output-type pdf.

If OCRmyPDF is given an image file as input, it will attempt to convert the
image to a PDF before processing.  For more control over the conversion of
images to PDF, use the Python package img2pdf or other image to PDF software.

For example, this command uses img2pdf to convert all .png files beginning
with the 'page' prefix to a PDF, fitting each image on A4-sized paper, and
sending the result to OCRmyPDF through a pipe.  img2pdf is a dependency of
ocrmypdf so it is already installed.

    img2pdf --pagesize A4 page*.png | ocrmypdf - myfile.pdf

Online documentation is located at:
    https://ocrmypdf.readthedocs.io/en/latest/introduction.html
 
Zuletzt bearbeitet:
  • Like
Reaktionen: peterhoffmann

mördock

Benutzer
Mitglied seit
04. Jan 2012
Beiträge
796
Punkte für Reaktionen
15
Punkte
44
Hallo,

leider hatte ich keine Zeit Deiner Bitte die neuste Version vorab zu testen nachzukommen. Aber gestern ist automatisch das Update installiert worden und nun läuft alles wieder einwandfrei. Danke.

#Mördock#
 
Mitglied seit
30. Nov 2014
Beiträge
43
Punkte für Reaktionen
3
Punkte
8
Hallo zusammen,

ich bin kurz vor dem durchdrehen. Seit ich von Version 0.17.1 auf Version 1.0.1 aktualisiert habe kann ich weder neue Profile erstellen, noch die alten ändern. (Mehrfaches neuladen im Browser, Edge und Chrome, Serverneustart) Es kommt entweder die Meldung, dass die Verbindung zurückgesetzt wurde oder "... hat die Verbindung unerwartet geschlossen. " Jetzt wollte ich mir die 0.17.1 wieder herunterladen, aber cphup.net meldet Error 500. Auch mit der Zip-Datei von geimist.eu lässt sich keine psk erstellen "Error: git is not installed." Hat jemand zufällig die "synOCR_v0.17.1.spk" zum Download?

Besten Dank!
 

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Ich kann mir nicht recht erklären, dass dein Problem durch das Update auf Version 1.0.1 hervorgerufen worden sein soll. So einen Einfluss auf die GUI hat es eigentlich nicht.
  • NAS schon mal neugestartet?
  • ggf. synOCR mit HyperBackup sichern, deinstallieren und neuinstallieren …
  • Haken "Schutz gegen Cross-Site-Request-Forgery-Attacken verbessern" ist gesetzt? (Systemsteuerung ? Sicherheit)
Was bei cphub.net los ist, weiß ich auch nicht … :unsure:
 

Anhänge

  • synOCR_v0.17.1.spk.zip
    993,2 KB · Aufrufe: 1
  • synOCR_v1.0.1.spk.zip
    4,1 MB · Aufrufe: 5
Mitglied seit
30. Nov 2014
Beiträge
43
Punkte für Reaktionen
3
Punkte
8
Danke!

Alle die genannten Punkte führten zu keiner Änderung!
Nach Installation von 0.17.1 kann ich neue Profile anlegen. Sobald ich aber die Einstellungen (0.16.x / 1.0.1) wiederherstelle scheint es auch bei 0.17.1 nicht mehr zu funktionieren. Werde mal die 0.16.0 testen. Kann man heruntergeladene Einstellungen manuell wieder einspielen?
 

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Wenn du dich auf die Konsole wagst, kannst du auch die heruntergeladene sqlite-DB tauschen.
Sie muss hier liegen /volume1/@appstore/synOCR/etc/synOCR.sqlite (hier, sofern unter volume1 installiert)
 
Mitglied seit
30. Nov 2014
Beiträge
43
Punkte für Reaktionen
3
Punkte
8
Scheint wieder die Anzahl der Tags zu sein - darüber habe ich schon mal berichtet, dass die Anzahl der möglichen Tags begrenzt zu sein scheint. => Wenn ich synOCR deinstalliere und das default Profil manuell konfiguriere, funktioniert alles - auch das einfügen der alten Tags und das anschließende speichern. Allerdings lässt sich dann kein Profil mehr hinzufügen, dann folgen die oben genannten Meldungen. Nimmt man die Tags wieder heraus und speichert das profil, dann lässt sie auch wieder ein neues Profil erstellen.
 

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Dafür gibt es ja (seit Version 0.17 ?) die Möglichkeit, die Tags in einer externen Datei unterzubringen (das Tagfeld enthält lediglich den absoluten Pfad zu der Datei). Die erweiteren Regeln im YAML-File ab Version 1.0.0 laufen ja eh über ein externes File.

Also: mal beherzt den blauen Button neben dem Tag-Feld in der Version 1.0.x anklicken :)
 
Mitglied seit
30. Nov 2014
Beiträge
43
Punkte für Reaktionen
3
Punkte
8
Hab ich gemacht, es wurde sogar die ungekürzten Tags (vorher hatte ich im Textfeld einige gelöscht) in die Datei übernommen! (y)
 
  • Like
Reaktionen: geimist

frankne

Benutzer
Mitglied seit
04. Aug 2020
Beiträge
13
Punkte für Reaktionen
0
Punkte
1
Hallo, erstmal vielen Dank an geimist für die super komfortable Oberfläche! Echt top und einfach zu bedienen.

Gibt es für den Rename-Syntax auch noch Variablen für die Stunden, Minuten und Sekunden?

Mein Scanner benennt die Dokumente immer Scan00x, sobald eine Datei konvertiert wurde, beginnt er wieder bei Scan001. Damit kann es passieren, dass es die Scan001 mehrfach gibt. Die Benennung nach Jahr, Monat und Tag is schon hilfreich, aber wenn ich jetzt noch die Konvertierungs-stunde, -minute und -sekunde hinzufügen könnte, wäre der Name einmalig.

Frank.
 

HerrZshay

Benutzer
Mitglied seit
06. Aug 2020
Beiträge
1
Punkte für Reaktionen
0
Punkte
1
Hi...I've downloaded the package but could you please explain exactly step by step how to install it? Thanks in advance!
 

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
  1. install the Synology-Pakage "Docker" (if not already done)
  2. open synOCR
  3. First adjust your installation in the Settings
    1. adjust the pathes (under 'General')
    2. all other settings are most likely optional

      Now, you can run synOCR by clicking the button "start manual synOCR run now" on site "Overview"

  4. To run synOCR regularly (which is recommended), next create an automated program launch.

    You have two options:
    Use the Scheduler for a planned synOCR start.
    Please note that the DSM safety advisor will criticize the additional cron entry (as unknown to DSM)!

    Or, alternatively, create a new task in the task planner with this program path (recommended if you need shorter intervals than "hourly"):
    /usr/syno/synoman/webman/3rdparty/synOCR/synOCR-start.sh

  5. Open the DSM control panel
    • Task Scheduler
    • Button Create
    • scheduled Task
    • User-defined script
    1. tab "General":
      • User root
      • any name under Task
      • set Enabled active
    2. tab "Schedule":
      • here desired interval (e.g. hourly)
    3. tab "Task Settings":
      • insert here the following path:
        /usr/syno/synoman/webman/3rdparty/synOCR/synOCR-start.sh
 
  • Like
Reaktionen: vater

lueddich

Benutzer
Mitglied seit
10. Dez 2012
Beiträge
52
Punkte für Reaktionen
8
Punkte
8
Hey Stephan,

seit ein paar Tagen funktioniert das Renaming bei mir nicht mehr. Im Log erhalte ich die Fehlermeldung

Code:
              ? search tags and date:
                source for tags is yaml based tag rule file [/volume1/Dokumenten-Bibliothek/_TagConfig_[profile_default].txt]
parse error: Invalid numeric literal at line 1, column 6
                  rename tag is: ""

Das komplette Log habe ich Dir hier einmal angehängt, auch die Konfig. In Zeile 1, Spalte 6 finde ich nichts, was mir Erhellung bringt. Hast Du eine Idee?

Danke!

Viele Grüße,
Jan
 

Anhänge

  • _TagConfig_[profile_default].txt
    30,3 KB · Aufrufe: 14
  • synOCR_2020-08-10_13-09-37.txt
    2,9 KB · Aufrufe: 3

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Das bezieht sich nicht auf die physischen Dateien sondern auf ein im Skript erstelltes Array.

Höchstwahrscheinlich besteht der Fehler bei dir seit einer Änderung der Regeldatei (da gibt es einen Fehler beim Interpretieren). Kannst du dich noch erinnern, was du geändert hast?
 

lueddich

Benutzer
Mitglied seit
10. Dez 2012
Beiträge
52
Punkte für Reaktionen
8
Punkte
8
Hi Stephan,

ich habe die Datei nur einmal über die GUI aus meinen alten Regeln erstellt. Sie ist vom 15.07. lt. Änderungsdatum und anhand meiner Datensicherungen konnte ich gerade nachvollziehen, dass es vorher keine Datei gab. Tatsächlich taucht in den Logs auch seitdem der Fehler auf, der Fehler ist also beim Konvertieren der alten 94 Tags hin zu der Datei passiert.

Viele Grüße,
Jan
 

geimist

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
04. Jan 2012
Beiträge
5.385
Punkte für Reaktionen
1.199
Punkte
234
Ich habe festgestellt, wenn eine Tagregel mit einer Zahl anfängt, dann kommt es zu diesem Parseerror. Ändere mal den Namen (setze z.B. einen Buchstaben davor [Regel 47 und 49]). Des Weiteren kommt es zu einem Error, wenn der Regelname einen Bindestrich im Namen hat. Bitte diesen auch ersetzen (z.B. mit einem Unterstrich).

Und dann nochmal testen.

Hier werde ich die automatische Konvertierung noch etwas anpassen müssen.
 


 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat