Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b403016d5b | ||
|
|
5a81823969 | ||
|
|
17801401cd | ||
|
|
5c7b2a2a36 | ||
|
|
1db06de287 | ||
|
|
3904178d44 | ||
|
|
8bb9c3610c | ||
|
|
7dcc382ccc | ||
|
|
b71fc807d2 | ||
|
|
15d28d970a | ||
|
|
e083a860e9 | ||
|
|
6463b9dd84 | ||
|
|
c873de6ca4 | ||
|
|
b70863b47e | ||
|
|
3546f84c6d |
+2
-1
@@ -1,2 +1,3 @@
|
||||
tmp/
|
||||
log/
|
||||
log/
|
||||
*.pyc
|
||||
Regular → Executable
+7
-6
@@ -4,7 +4,8 @@
|
||||
##############################################################################
|
||||
|
||||
# Import required scripts
|
||||
. "`dirname $0`/src/config.sh"
|
||||
BASEPATH="$(dirname $(readlink -f $0))"
|
||||
. "$BASEPATH/src/config.sh"
|
||||
|
||||
# Set variables corresponding to the input parameters
|
||||
ARGUMENTS="$@"
|
||||
@@ -39,7 +40,7 @@ Usage: OCRmyPDF.sh [-h] [-v] [-g] [-k] [-d] [-c] [-i] [-o dpi] [-f] [-l languag
|
||||
an oversampled image having the latter dpi value. This can improve the OCR results but can lead to a larger output PDF file.
|
||||
(default: no oversampling performed)
|
||||
-f : Force to OCR the whole document, even if some page already contain font data
|
||||
(which should not be the case for PDF files built from scnanned images)
|
||||
(which should not be the case for PDF files built from scanned images)
|
||||
-l : Set the language of the PDF file in order to improve OCR results (default "eng")
|
||||
Any language supported by tesseract is supported (Tesseract uses 3-character ISO 639-2 language codes)
|
||||
Multiple languages may be specified, separated by '+' characters.
|
||||
@@ -128,7 +129,7 @@ FILE_OUTPUT_PDFA="`absolutePath "$2"`"
|
||||
|
||||
|
||||
# set script path as working directory
|
||||
cd "`dirname $0`"
|
||||
cd "$BASEPATH"
|
||||
|
||||
[ $VERBOSITY -ge $LOG_DEBUG ] && echo "$TOOLNAME version: $VERSION"
|
||||
[ $VERBOSITY -ge $LOG_DEBUG ] && echo "Arguments: $ARGUMENTS"
|
||||
@@ -145,7 +146,7 @@ cd "`dirname $0`"
|
||||
! command -v python2 > /dev/null && echo "Please install python v2.x. Exiting..." && exit $EXIT_MISSING_DEPENDENCY
|
||||
! python2 -c 'import lxml' 2>/dev/null && echo "Please install the python library lxml. Exiting..." && exit $EXIT_MISSING_DEPENDENCY
|
||||
! python2 -c 'import reportlab' 2>/dev/null && echo "Please install the python library reportlab. Exiting..." && exit $EXIT_MISSING_DEPENDENCY
|
||||
! command -v gs > /dev/null && echo "Please install ghostcript. Exiting..." && exit $EXIT_MISSING_DEPENDENCY
|
||||
! command -v gs > /dev/null && echo "Please install ghostscript. Exiting..." && exit $EXIT_MISSING_DEPENDENCY
|
||||
! command -v java > /dev/null && echo "Please install java. Exiting..." && exit $EXIT_MISSING_DEPENDENCY
|
||||
|
||||
|
||||
@@ -162,7 +163,7 @@ tesstooold=$(echo "`echo $tessversion | sed s/[.]//2`-`echo $reqtessversion | se
|
||||
|
||||
# ensure the right GNU parallel version is installed
|
||||
# older version do not support -q flag (required to escape special characters)
|
||||
reqparallelversion="20130222"
|
||||
reqparallelversion="20121122"
|
||||
parallelversion=`parallel --minversion 0`
|
||||
! parallel --minversion "$reqparallelversion" > /dev/null \
|
||||
&& echo "Please install GNU parallel ${reqparallelversion} or newer (currently installed version is ${parallelversion})" && exit $EXIT_MISSING_DEPENDENCY
|
||||
@@ -292,4 +293,4 @@ END=`date +%s`
|
||||
[ $VERBOSITY -ge $LOG_DEBUG ] && echo "Script took $(($END-$START)) seconds"
|
||||
|
||||
|
||||
[ $pdf_valid -ne 1 ] && exit $EXIT_INVALID_OUPUT_PDFA || exit 0
|
||||
[ $pdf_valid -ne 1 ] && exit $EXIT_INVALID_OUTPUT_PDFA || exit 0
|
||||
|
||||
@@ -5,6 +5,42 @@ Please always read this file before installing the package
|
||||
|
||||
Download software here: https://github.com/fritz-hh/OCRmyPDF/tags
|
||||
|
||||
v2.1-stable (2014-09-20):
|
||||
=======
|
||||
|
||||
New features
|
||||
------------
|
||||
|
||||
- None
|
||||
|
||||
Changes
|
||||
-------
|
||||
|
||||
- None
|
||||
|
||||
Fixes
|
||||
-----
|
||||
|
||||
- Allow execution via simlink
|
||||
- Add support for tesseract 3.03
|
||||
- Add support for newer version of reportlab
|
||||
- Lowered minimum version of gnu parallel
|
||||
- Various typo
|
||||
|
||||
Tested with
|
||||
-----------
|
||||
|
||||
- Operating system: FreeBSD 9.1
|
||||
- Dependencies:
|
||||
- parallel 20130222
|
||||
- poppler-utils 0.22.2
|
||||
- ImageMagick 6.8.0-7 2013-03-30
|
||||
- Unpaper 0.3
|
||||
- tesseract 3.02.02
|
||||
- Python 2.7.3
|
||||
- ghoscript (gs): 9.06
|
||||
- java: openjdk version "1.7.0_17"
|
||||
|
||||
v2.0-stable (2014-01-25):
|
||||
=======
|
||||
|
||||
|
||||
+2
-2
@@ -9,13 +9,13 @@ DEFAULT_DPI=300 # dpi value used as fall back if the page dpi cannot be deter
|
||||
#####################################################################################
|
||||
|
||||
TOOLNAME="OCRmyPDF"
|
||||
VERSION="v2.0-stable"
|
||||
VERSION="v2.1-stable"
|
||||
|
||||
# possible exit codes
|
||||
EXIT_BAD_ARGS="1"
|
||||
EXIT_BAD_INPUT_FILE="2"
|
||||
EXIT_MISSING_DEPENDENCY="3"
|
||||
EXIT_INVALID_OUPUT_PDFA="4"
|
||||
EXIT_INVALID_OUTPUT_PDFA="4"
|
||||
EXIT_FILE_ACCESS_ERROR="5"
|
||||
EXIT_OTHER_ERROR="15"
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ from PIL import Image
|
||||
import re, sys
|
||||
import argparse
|
||||
|
||||
|
||||
def monkeypatch_method(cls):
|
||||
'''
|
||||
Override a class method at runtime.
|
||||
@@ -47,8 +46,13 @@ def PIL_imagedata(self):
|
||||
|
||||
from reportlab.lib.utils import import_zlib
|
||||
from reportlab import rl_config
|
||||
from reportlab.pdfbase.pdfutils import _AsciiBase85Encode, _chunker
|
||||
|
||||
from reportlab.pdfbase.pdfutils import _chunker
|
||||
# in order to support both newer and older versions of reportlab
|
||||
try:
|
||||
from reportlab.pdfbase.pdfutils import _AsciiBase85Encode
|
||||
except ImportError:
|
||||
from reportlab.pdfbase.pdfutils import asciiBase85Encode as _AsciiBase85Encode
|
||||
|
||||
self.source = 'PIL'
|
||||
zlib = import_zlib()
|
||||
if not zlib:
|
||||
|
||||
+8
-1
@@ -187,7 +187,14 @@ fi
|
||||
[ $VERBOSITY -ge $LOG_DEBUG ] && echo "Page $page: Performing OCR"
|
||||
! tesseract -l "$LAN" "$curImgPixmapClean" "$curHocr" hocr $TESS_CFG_FILES 1> /dev/null 2> /dev/null \
|
||||
&& echo "Could not OCR file \"$curImgPixmapClean\". Exiting..." && exit $EXIT_OTHER_ERROR
|
||||
mv "$curHocr.html" "$curHocr"
|
||||
# Tesseract names the output files differently in some distributions.
|
||||
if [ -e "$curHocr.html" ]; then
|
||||
mv "$curHocr.html" "$curHocr"
|
||||
elif [ -e "$curHocr.hocr" ]; then
|
||||
mv "$curHocr.hocr" "$curHocr"
|
||||
elif [ ! -e "$curHocr" ]; then
|
||||
echo "\"$curHocr[.html|.hocr]\" not found. Exiting..." && exit $EXIT_OTHER_ERROR
|
||||
fi
|
||||
|
||||
# embed text and image to new pdf file
|
||||
if [ "$PREPROCESS_CLEANTOPDF" -eq "1" ]; then
|
||||
|
||||
Reference in New Issue
Block a user