Compare commits

...
13 Commits
11 changed files with 34 additions and 45 deletions
+1
View File
@@ -0,0 +1 @@
ref-names: $Format:%D$
+3 -1
View File
@@ -5,4 +5,6 @@
# (binary is a macro for -text -diff) # (binary is a macro for -text -diff)
*.jar binary *.jar binary
*.pdf binary *.pdf binary
*.PDF binary *.PDF binary
.git_archival.txt export-subst
+4 -4
View File
@@ -116,8 +116,8 @@ Install or upgrade the required Homebrew packages, if any are missing::
brew install qpdf brew install qpdf
brew install ghostscript brew install ghostscript
brew install python3 brew install python3
brew install libxml2 brew install libxml2 libffi leptonica
brew install leptonica brew install unpaper # optional
brew install tesseract brew install tesseract
Update the homebrew pip and install Pillow:: Update the homebrew pip and install Pillow::
@@ -252,11 +252,11 @@ In case you detect an issue, please:
Press & Media Press & Media
------------- -------------
- `c't 1-2014, page 59 <http://www.heise.de/ct/inhalt/2014/1/58/>`__: - `c't 1-2014, page 59 <http://heise.de/-2279695>`__:
Detailed presentation of OCRmyPDF v1.0 in the leading German IT Detailed presentation of OCRmyPDF v1.0 in the leading German IT
magazine c't magazine c't
- `heise Open Source, 09/2014: Texterkennung mit - `heise Open Source, 09/2014: Texterkennung mit
OCRmyPDF <http://www.heise.de/-2356670>`__ OCRmyPDF <http://heise.de/-2356670>`__
Disclaimer Disclaimer
---------- ----------
+15 -1
View File
@@ -6,15 +6,29 @@ Please always read this file before installing the package
Download software here: https://github.com/jbarlow83/OCRmyPDF/tags Download software here: https://github.com/jbarlow83/OCRmyPDF/tags
v4.0.4: v4.0.6:
=======
- Update install instructions
- Provide a sRGB profile instead of using Ghostscript's
v4.0.5:
======= =======
Fixes Fixes
----- -----
- Remove some verbose debug messages from v4.0.4
- Fixed temporary that wasn't being deleted
- DPI is now calculated correctly for cropped images, along with other image transformations - DPI is now calculated correctly for cropped images, along with other image transformations
- Inline images are now checked during DPI calculation instead of rejecting the image - Inline images are now checked during DPI calculation instead of rejecting the image
v4.0.4:
=======
Released with verbose debug message turned on. Do not use. Skip to v4.0.5.
v4.0.3: v4.0.3:
======= =======
Binary file not shown.
+2 -1
View File
@@ -5,6 +5,7 @@ from tempfile import NamedTemporaryFile
from subprocess import Popen, PIPE, check_call from subprocess import Popen, PIPE, check_call
from shutil import copy from shutil import copy
from . import get_program from . import get_program
from .pdfa import SRGB_ICC_PROFILE
def rasterize_pdf(input_file, output_file, xres, yres, raster_device, log, def rasterize_pdf(input_file, output_file, xres, yres, raster_device, log,
@@ -52,7 +53,7 @@ def generate_pdfa(pdf_pages, output_file, threads=1):
"-dJPEGQ=95", "-dJPEGQ=95",
"-dPDFA=2", "-dPDFA=2",
"-sPDFACompatibilityPolicy=2", "-sPDFACompatibilityPolicy=2",
"-sOutputICCProfile=srgb.icc", "-sOutputICCProfile=" + SRGB_ICC_PROFILE,
"-sOutputFile=" + gs_pdf.name, "-sOutputFile=" + gs_pdf.name,
] ]
args_gs.extend(pdf_pages) args_gs.extend(pdf_pages)
+1 -1
View File
@@ -378,7 +378,7 @@ def cleanup_working_files(*args):
@transform( @transform(
input=options.input_file, input=options.input_file,
filter=formatter('(?i)\.pdf'), filter=formatter('(?i)\.pdf'),
output=work_folder + '{basename[0]}.repaired.pdf', output=os.path.join(work_folder, '{basename[0]}.repaired.pdf'),
extras=[_log, _pdfinfo, _pdfinfo_lock]) extras=[_log, _pdfinfo, _pdfinfo_lock])
def repair_pdf( def repair_pdf(
input_file, input_file,
-3
View File
@@ -82,7 +82,6 @@ def _interpret_contents(contentstream):
image_raster_settings = [] image_raster_settings = []
inline_images = [] inline_images = []
print(operations)
for op in operations: for op in operations:
operands, command = op operands, command = op
if command == b'q': if command == b'q':
@@ -182,7 +181,6 @@ def _get_dpi(ctm_shorthand, image_size):
def _find_page_images(page, pageinfo, contentsinfo): def _find_page_images(page, pageinfo, contentsinfo):
for n, im in enumerate(contentsinfo.inline_images): for n, im in enumerate(contentsinfo.inline_images):
print(n)
settings, shorthand = im settings, shorthand = im
image = {} image = {}
image['name'] = str('inline-%02d' % n) image['name'] = str('inline-%02d' % n)
@@ -295,7 +293,6 @@ def _pdf_get_pageinfo(infile, pageno: int):
return pageinfo return pageinfo
contentsinfo = _interpret_contents(contentstream) contentsinfo = _interpret_contents(contentstream)
print(contentsinfo)
pageinfo['images'] = [im for im in _find_page_images( pageinfo['images'] = [im for im in _find_page_images(
page, pageinfo, contentsinfo)] page, pageinfo, contentsinfo)]
+7 -33
View File
@@ -5,10 +5,13 @@
from __future__ import print_function, absolute_import, division from __future__ import print_function, absolute_import, division
from string import Template from string import Template
from subprocess import Popen, PIPE
import os
import codecs import codecs
from . import get_program import pkg_resources
ICC_PROFILE_RELPATH = 'data/sRGB_IEC61966-2-1_black_scaled.icc'
SRGB_ICC_PROFILE = pkg_resources.resource_filename(
'ocrmypdf', ICC_PROFILE_RELPATH)
# This is a template written in PostScript which is needed to create PDF/A # This is a template written in PostScript which is needed to create PDF/A
@@ -93,38 +96,9 @@ def _get_pdfa_def(icc_profile, icc_identifier, pdfmark):
return result return result
def _get_postscript_icc_path():
"Parse Ghostscript's help message to find where iccprofiles are stored"
p_gs = Popen([get_program('gs'), '--help'], close_fds=True,
universal_newlines=True,
stdout=PIPE, stderr=PIPE)
out, _ = p_gs.communicate()
lines = out.splitlines()
def search_paths(lines):
seeking = True
for line in lines:
if seeking:
if line.startswith('Search path'):
seeking = False
continue
else:
if line.strip().startswith('/'):
yield from (
path.strip() for path in line.split(':')
if path.strip() != '')
for root in search_paths(lines):
path = os.path.realpath(os.path.join(root, '../iccprofiles'))
if os.path.exists(path):
return path
raise FileNotFoundError("Could not find Ghostscript's iccprofiles")
def generate_pdfa_def(target_filename, pdfmark, icc='sRGB'): def generate_pdfa_def(target_filename, pdfmark, icc='sRGB'):
if icc == 'sRGB': if icc == 'sRGB':
icc_profile = os.path.join(_get_postscript_icc_path(), 'srgb.icc') icc_profile = SRGB_ICC_PROFILE
else: else:
raise NotImplementedError("Only supporting sRGB") raise NotImplementedError("Only supporting sRGB")
+1 -1
View File
@@ -209,7 +209,6 @@ setup(
], ],
setup_requires=[ setup_requires=[
'setuptools_scm', 'setuptools_scm',
'setuptools_scm_git_archive',
'cffi>=1.5.0', 'cffi>=1.5.0',
'pytest-runner' 'pytest-runner'
], ],
@@ -231,5 +230,6 @@ setup(
'ocrmypdf = ocrmypdf.main:run_pipeline' 'ocrmypdf = ocrmypdf.main:run_pipeline'
], ],
}, },
package_data={'ocrmypdf': ['data/sRGB_IEC61966-2-1_black_scaled.icc']},
include_package_data=True, include_package_data=True,
zip_safe=False) zip_safe=False)
Binary file not shown.