Compare commits

..
16 Commits
Author SHA1 Message Date
James R. Barlow aff597cef4 v4.2.5: update release notes, fix silly typo in pageinfo.py 2016-10-13 13:26:39 -07:00
James R. Barlow 61b05b3dee Fix issue: BitsPerComponent is an optional field, sometimes omitted 2016-10-13 13:15:27 -07:00
Julian Kahnertandjbarlow83 453c4ef602 Update README.rst (#98)
`brew install tesseract` just installed the english language pack not French, German or Spanish
2016-10-12 11:20:58 -07:00
James R. Barlow cf4b04f92d The main 'quick' test should be a file that OCRs to recognizable text 2016-10-07 16:25:34 -07:00
James R. Barlow 06c6999987 Merge commit '07891d994aab92e7a14aebe1ac509aab2d4f170c' 2016-10-07 12:45:56 -07:00
James R. Barlow 013c5a369f Replace redacted file with an OCR-able file 2016-10-07 12:45:22 -07:00
James R. Barlow 07891d994a Replace redacted file with an OCR-able file 2016-10-07 12:44:49 -07:00
James R. Barlow 6baf8668a6 Replace with non-free file milk.pdf with free equivalent 2016-10-06 13:10:28 -07:00
James R. Barlow 4ba2962c56 Comment on non-free files 2016-10-05 16:48:16 -07:00
James R. Barlow 7ad92f5db4 Merge branch 'master' of https://github.com/jbarlow83/OCRmyPDF 2016-10-05 16:39:00 -07:00
James R. Barlow 4dad09cc91 resources/README: replace the other large table with a list table 2016-10-05 16:38:51 -07:00
Sean Whittonandjbarlow83 7b2e0c7a7a also exclude .git in pytest.ini (#94) 2016-09-15 08:56:14 -07:00
Sean Whittonandjbarlow83 7f08f15fc9 pytest skipif for milk.pdf test (#95)
Skip the test if the fair use restricted milk.pdf is not present.
2016-09-15 08:55:31 -07:00
James R. Barlow 825c0f8b2a Note that milk.pdf is non-free, start using list-tables 2016-09-10 14:44:00 -07:00
James R. Barlow dbe880bc41 Update tesseract supported languages 2016-09-09 12:55:07 -07:00
James R. Barlow 220f1ce161 tasks.py: stop tracking this file for now
This helper script is still in development and needs to be changed each
release, which breaks the release.

It shouldn't be in MANIFEST.in at all because it's not part of a
distribution.
2016-09-04 10:55:57 -07:00
11 changed files with 84 additions and 158 deletions
+1
View File
@@ -3,6 +3,7 @@
*.sublime-*
venv-*/
pyvenv.cfg
tasks.py
# Package building
*.egg-info/
+1
View File
@@ -32,6 +32,7 @@ recursive-exclude .github *
recursive-include ocrmypdf/data *
recursive-include share *
include *.py
exclude tasks.py
# code
recursive-include ocrmypdf *.py
+2 -2
View File
@@ -19,7 +19,7 @@ Main features
- Processes pages in parallel when more than one CPU core is
available
- Uses `Tesseract OCR <https://github.com/tesseract-ocr/tesseract>`_ engine
- Supports the `39 languages <https://code.google.com/p/tesseract-ocr/downloads/list>`_ recognized by Tesseract
- Supports more than `100 languages <https://github.com/tesseract-ocr/tessdata>`_ recognized by Tesseract
- Battle-tested on thousands of PDFs, a test suite and continuous integration
For details: please consult the `release notes <RELEASE_NOTES.rst>`_.
@@ -162,7 +162,7 @@ Install the required Tesseract OCR engine with the language packs you plan to us
.. code-block:: bash
brew install tesseract # Option 1: for English, French, German, Spanish
brew install tesseract # Option 1: for English
.. code-block:: bash
+7
View File
@@ -4,6 +4,13 @@ RELEASE NOTES
OCRmyPDF uses `semantic versioning <http://semver.org/>`_.
v4.2.5:
=======
- Fixed an issue (#100) with PDFs that omit the optional /BitsPerComponent parameter on images
- Removed non-free file milk.pdf
v4.2.4:
=======
+8 -2
View File
@@ -211,7 +211,10 @@ def _find_page_inline_images(page, pageinfo, contentsinfo):
image['name'] = str('inline-%02d' % n)
image['width'] = inline.settings['/W']
image['height'] = inline.settings['/H']
image['bpc'] = inline.settings['/BPC']
if '/BPC' in inline.settings:
image['bpc'] = inline.settings['/BPC']
else:
image['bpc'] = 8
image['color'] = FRIENDLY_COLORSPACE.get(inline.settings['/CS'], '-')
image['comp'] = FRIENDLY_COMP.get(image['color'], '?')
if '/F' in inline.settings:
@@ -244,7 +247,10 @@ def _find_page_regular_images(page, pageinfo, contentsinfo):
image['name'] = str(xobj)
image['width'] = pdfimage['/Width']
image['height'] = pdfimage['/Height']
image['bpc'] = pdfimage['/BitsPerComponent']
if '/BitsPerComponent' in pdfimage:
image['bpc'] = pdfimage['/BitsPerComponent']
else:
image['bpc'] = 8
# Fixme: this is incorrectly treats explicit masks as stencil masks,
# but good enough for now. Explicit masks have /ImageMask true but are
+1 -1
View File
@@ -1,2 +1,2 @@
[pytest]
norecursedirs = lib .pc
norecursedirs = lib .pc .git
-111
View File
@@ -1,111 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# © 2016 James R. Barlow: github.com/jbarlow83
# Release sanity checking
import argparse
from subprocess import run, PIPE, DEVNULL, STDOUT, CalledProcessError
from git import Repo, Remote, PushInfo
import logging
import re
import sys
import os
logging.basicConfig(level=logging.INFO)
REMOTE_ERROR_FLAGS = \
PushInfo.REJECTED | PushInfo.NO_MATCH | PushInfo.REMOTE_REJECTED | \
PushInfo.REMOTE_FAILURE | PushInfo.DELETED | PushInfo.ERROR
def test_repo(repo):
assert not repo.is_dirty(), "Repository is dirty"
if repo.untracked_files:
logging.warning('Some files are untracked:')
logging.warning('\n' + '\n'.join(repo.untracked_files))
assert repo.active_branch.name == 'master', 'Not on branch master'
def travis(args):
repo = Repo('.')
test_repo(repo)
git_describe = repo.git.describe()
try:
env = os.environ.copy()
env['SETUPTOOLS_SCM_PRETEND_VERSION'] = git_describe
proc = run(['check-manifest'], check=True, universal_newlines=True, stdout=PIPE, stderr=STDOUT, env=env)
logging.info(proc.stdout)
except CalledProcessError as e:
logging.error('MANIFEST.in error')
logging.error(e.stdout)
sys.exit(1)
run(['python3', 'setup.py', 'build'], check=True)
origin = Remote(repo, 'jbarlow')
result = origin.push(refspec='master:master')[0]
if result.flags & REMOTE_ERROR_FLAGS:
logging.error(result.summary)
sys.exit(1)
else:
logging.info(result.summary)
logging.info("Pushed to Travis CI")
logging.info("If this passes, git tag and release")
def release(args):
repo = Repo('.')
test_repo(repo)
git_describe = repo.git.describe()
assert git_describe.startswith('v') and not '-' in git_describe and not '+ng' in git_describe, \
"Not tagged properly for release: " + git_describe
plain_version = git_describe[1:] # without 'v' prefix
with open('RELEASE_NOTES.rst') as f:
notes = f.read()
assert plain_version in notes, "Version not mentioned in release notes"
proc = run(['python3', 'setup.py', 'sdist', 'bdist_wheel'], universal_newlines=True, check=True, stdout=PIPE, stderr=STDOUT)
logging.info(proc.stdout)
origin = Remote(repo, 'jbarlow')
result = origin.push(refspec='master:master', tags=True)[0]
if result.flags & REMOTE_ERROR_FLAGS:
logging.error(result.summary)
sys.exit(1)
else:
logging.info(result.summary)
run(['twine', 'upload', '-r', 'pypitest',
'dist/ocrmypdf-{}.tar.gz'.format(plain_version),
'dist/ocrmypdf-{}-py34-none-any.whl'.format(plain_version)], check=True, universal_newlines=True, stdout=PIPE)
parser = argparse.ArgumentParser(description="ocrmypdf release tasks")
subparsers = parser.add_subparsers()
push_travis = subparsers.add_parser(
'push-travis', description="Push master to travis for testing")
push_travis.set_defaults(func=travis)
release_parser = subparsers.add_parser(
'release', description="Release to PyPI etc")
release_parser.set_defaults(func=release)
def main():
args = parser.parse_args()
args.func(args)
if __name__ == '__main__':
main()
+59 -39
View File
@@ -9,20 +9,28 @@ Files derived from free sources
These test resources come from free sources, under either public domain or Creative Commons licenses.
In some cases they were converted from one image format to another without other changes.
+---------------------+--------------------------------------------------------------------------------+
| File | Source |
+=====================+================================================================================+
| c02-22.pdf | `Project Gutenberg`_, Adventures of Huckleberry Finn, page 22 |
+---------------------+--------------------------------------------------------------------------------+
| congress.jpg | `US Congressional Records`_ (Public Domain) |
+---------------------+--------------------------------------------------------------------------------+
| graph.pdf | `Wikimedia: Pandas text analysis.png`_ (Public Domain) |
+---------------------+--------------------------------------------------------------------------------+
| lichtenstein.pdf | `Wikimedia: JPEG2000 Lichtenstein`_ (Creative Commons BY-SA 3.0) |
+---------------------+--------------------------------------------------------------------------------+
| LinnSequencer.jpg, | `Wikimedia: LinnSequencer`_ (Creative Commons BY-SA 3.0) |
| linn.pdf, linn.txt | |
+---------------------+--------------------------------------------------------------------------------+
.. list-table::
:widths: 20 50 30
:header-rows: 1
* - File
- Source
- License
* - c02-22.pdf
- `Project Gutenberg`_, Adventures of Huckleberry Finn, page 22
- Public Domain
* - congress.jpg
- `US Congressional Records`_
- Public Domain
* - graph.pdf
- `Wikimedia: Pandas text analysis.png`_
- Public Domain
* - lichtenstein.pdf
- `Wikimedia: JPEG2000 Lichtenstein`_
- Creative Commons BY-SA 3.0
* - LinnSequencer.jpg, linn.pdf, linn.txt
- `Wikimedia: LinnSequencer`_
- Creative Commons BY-SA 3.0
Files generated for this project
@@ -31,31 +39,43 @@ Files generated for this project
The following test resources were crafted specifically for this project, and can be used
under the terms of the license in LICENSE.rst.
+---------------------+-----------------------+---------------------------------------------------------+
| File | Contributor | Purpose |
+---------------------+-----------------------+---------------------------------------------------------+
| aspect.pdf | @jbarlow83 | test image with 200 x 100 DPI resolution |
+---------------------+-----------------------+---------------------------------------------------------+
| blank.pdf | @jbarlow83 | blank PDF |
+---------------------+-----------------------+---------------------------------------------------------+
| cmyk.pdf | @jbarlow83 | a CMYK image created in Photoshop |
+---------------------+-----------------------+---------------------------------------------------------+
| enormous.pdf | @jbarlow83 | very large PDF page |
+---------------------+-----------------------+---------------------------------------------------------+
| francais.pdf | @jbarlow83 | a page containing French accents (diacritics) |
+---------------------+-----------------------+---------------------------------------------------------+
| hugemono.pdf | @jbarlow83 | large monochrome 35000x35000 image in JBIG2 encoding |
+---------------------+-----------------------+---------------------------------------------------------+
| invalid.pdf | @jbarlow83 | a PDF file header followed by EOF marker |
+---------------------+-----------------------+---------------------------------------------------------+
| masks.pdf | @supergrobi | file containing explicit masks and a stencil mask |
| | | drawn without a proper transformation matrix; printout |
| | | of a German Wikipedia article (Creative Commons BY-SA) |
+---------------------+-----------------------+---------------------------------------------------------+
| milk.pdf | @lowesjam | linearized PDF containing some indirect objects |
+---------------------+-----------------------+---------------------------------------------------------+
| missing_docinfo.pdf | @jbarlow83 | PDF file with no /DocumentInfo section |
+---------------------+-----------------------+---------------------------------------------------------+
.. list-table::
:widths: 20 20 60
:header-rows: 1
* - File
- Contributor
- Purpose
* - aspect.pdf
- @jbarlow83
- test image with 200 x 100 DPI resolution
* - blank.pdf
- @jbarlow83
- blank PDF
* - cmyk.pdf
- @jbarlow83
- a CMYK image created in Photoshop
* - enormous.pdf
- @jbarlow83
- very large PDF page
* - epson.pdf
- @lowesjam
- a linearized PDF containing some unusual indirect objects, created by an Epson printer; printout of a Wikipedia article (CC BY-SA)
* - francais.pdf
- @jbarlow83
- a page containing French accents (diacritics)
* - hugemono.pdf
- @jbarlow83
- large monochrome 35000x35000 image in JBIG2 encoding
* - invalid.pdf
- @jbarlow83
- a PDF file header followed by EOF marker
* - masks.pdf
- @supergrobi
- file containing explicit masks and a stencil mask drawn without a proper transformation matrix; printout of a German Wikipedia article (CC BY-SA)
* - missing_docinfo.pdf
- @jbarlow83
- PDF file with no /DocumentInfo section
Assemblies
==========
Binary file not shown.
Binary file not shown.
+5 -3
View File
@@ -124,8 +124,8 @@ def spoof_tesseract_big_image_error():
return spoof('tesseract', 'tesseract_big_image_error.py')
def test_quick(spoof_tesseract_noop):
check_ocrmypdf('c02-22.pdf', 'test_quick.pdf', env=spoof_tesseract_noop)
def test_quick(spoof_tesseract_cache):
check_ocrmypdf('ccitt.pdf', 'test_quick.pdf', env=spoof_tesseract_cache)
def test_deskew(spoof_tesseract_noop):
@@ -635,4 +635,6 @@ def test_masks(spoof_tesseract_noop):
def test_linearized_pdf_and_indirect_object(spoof_tesseract_noop):
check_ocrmypdf('milk.pdf', 'test_milk.pdf', env=spoof_tesseract_noop)
check_ocrmypdf(
'epson.pdf', 'test_epson.pdf',
env=spoof_tesseract_noop)