diff --git a/.gitignore b/.gitignore index 1e47924e..2e738aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,31 @@ -tmp/ -log/ +# Development environment *.pyc -tests/output/ -.ruffus_history.sqlite *.sublime-* -/*.pdf -build/ -dist/ -*.egg-info/ -venv/ venv-3.4/ venv-3.5/ -*/test/output -bin/ -include/ -lib/ -pip-selfcheck.json +venv/ pyvenv.cfg -htmlcov/ -.coverage + +# Package building +*.egg-info/ .cache/ +.eggs/ +build/ +dist/ + +# Automatically generated files +ocrmypdf/lib/_*.py +ocrmypdf/version.py + +# Code coverage +.coverage +htmlcov/ + +# Testing +log/ +/*.pdf .ipynb_checkpoints/ tests/cache/ +tests/output/ tests/resources/private -ocrmypdf/version.py \ No newline at end of file +tmp/ diff --git a/README.rst b/README.rst index b78862d1..e80c4639 100644 --- a/README.rst +++ b/README.rst @@ -11,12 +11,7 @@ Main features `PDF/A `__ file from a regular PDF - Places OCR text accurately below the image to ease copy / paste - Keeps the exact resolution of the original embedded images - - - or if requested oversamples the images before OCRing so as to get - better results - -- When possible, inserts OCR information as a "lossless" operation without transcoding - images or rendering vector information +- When possible, inserts OCR information as a "lossless" operation without rendering vector information - Keeps file size about the same - If requested deskews and/or cleans the image before performing OCR - Validates input and output files diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index ea4241dd..3ed6177d 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -12,13 +12,21 @@ v3.2: New features ------------ -- Lossless reconstruction: when possible, OCRmyPDF will inject text layers without transcoding - images or otherwise manipulating the content and layout of a PDF page. The overall PDF is still reconstructed. +- Lossless reconstruction: when possible, OCRmyPDF will inject text layers without + otherwise manipulating the content and layout of a PDF page. For example, a PDF containing a mix + of vector and raster content would see the vector content preserved. Images may still be transcoded + during PDF/A conversion. (``--deskew`` and ``--clean-final`` disable this mode, necessarily.) - New argument ``--tesseract-pagesegmode`` allows you to pass page segmentation arguments to Tesseract OCR. This helps for two column text and other situations that confuse Tesseract. - Added a new "polyglot" version of the Docker image, that generates Tesseract with all languages packs installed, for the polyglots among us. It is much larger. +Changes +------- + +- JPEG transcoding quality is now 95 instead of the default 75. Bigger file sizes for less degradation. + + v3.1.1: ======= diff --git a/ocrmypdf/ghostscript.py b/ocrmypdf/ghostscript.py index 216dc9e0..1a6c0ec7 100644 --- a/ocrmypdf/ghostscript.py +++ b/ocrmypdf/ghostscript.py @@ -45,6 +45,7 @@ def generate_pdfa(pdf_pages, output_file, threads=1): "-sDEVICE=pdfwrite", "-sColorConversionStrategy=/RGB", "-sProcessColorModel=DeviceRGB", + "-dJPEGQ=95", "-dPDFA=2", "-sPDFACompatibilityPolicy=2", "-sOutputICCProfile=srgb.icc", diff --git a/tests/spoof/tesseract_noop.py b/tests/spoof/tesseract_noop.py index ee7cadae..b0832dfe 100755 --- a/tests/spoof/tesseract_noop.py +++ b/tests/spoof/tesseract_noop.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys import img2pdf +from PIL import Image VERSION_STRING = '''tesseract 3.04.00 @@ -40,9 +41,12 @@ def main(): print('List of available languages (1):\neng', file=sys.stderr) sys.exit(0) elif sys.argv[-1] == 'hocr': + inputf = sys.argv[-3] output = sys.argv[-2] - with open(output + '.hocr', 'w', encoding='utf-8') as f: - f.write(HOCR_TEMPLATE.format('1000', '1000')) + with Image.open(inputf) as im, \ + open(output + '.hocr', 'w', encoding='utf-8') as f: + w, h = im.size + f.write(HOCR_TEMPLATE.format(str(w), str(h))) elif sys.argv[-1] == 'pdf': inputf = sys.argv[-3] output = sys.argv[-2]