Compare commits

...
18 Commits
Author SHA1 Message Date
James R. Barlow e6a7b58863 Merge branch 'de-gpl' 2020-08-12 12:20:38 -07:00
James R. Barlow 56184a762f Issue template:Give stronger hints about sample input files 2020-08-12 12:12:37 -07:00
James R. Barlow 07ab98f5af docs: mention that Ghostscript PDF/A can swallow hyperlinks
Addresses #605
2020-08-12 12:12:00 -07:00
James R. Barlow 04fb1892b4 Don't ask for sample files anymore 2020-08-12 11:40:42 -07:00
James R. Barlow 173ce2f215 v10.3.3 release notes 2020-08-07 02:23:21 -07:00
James R. Barlow 9b641055e1 Fix KeyError: 'dpi' when using --threshold on image to PDF
Fixes #607
2020-08-07 02:21:02 -07:00
James R. Barlow 4fa28d7e74 v10.3.2 release notes 2020-08-05 01:36:56 -07:00
James R. Barlow bed74501fc Fix test breakage in validation
Broken in commit 4cc0dc
2020-08-05 01:35:26 -07:00
James R. Barlow 8c90f7c972 Replace GPLv3-derived PDF/A template with PostScript generator 2020-08-05 01:30:45 -07:00
James R. Barlow aa0ec40102 Change license of all GPLv3 files to MPL-2.0
https://github.com/jbarlow83/OCRmyPDF/issues/600
2020-08-05 00:44:42 -07:00
James R. Barlow 12c567ee10 Copyright cleanup: relicense example_plugin.py
The author is relicensing this file to MIT.
2020-08-05 00:15:33 -07:00
James R. Barlow d39778ce3a Clarify copyright status of misc/batch.py, synology.py
At the time these files were contributed there was no discussion
of the license that the authors wanted to use, but the project was
MIT licensed at the time. As such, these files deemed to be MIT licensed.

https://github.com/jbarlow83/OCRmyPDF/issues/600
2020-08-05 00:12:44 -07:00
James R. Barlow e824cdbc4e Change license of misc/watcher.py to MIT
The authors of this file all agreed to relicense it under the MIT license.

https://github.com/jbarlow83/OCRmyPDF/issues/600
2020-08-04 23:57:41 -07:00
James R. Barlow 1d91c09963 Clarify license status of misc/completion/* files
These files were contributed when the project license was GPLv3. On
discussion, all known authors of these files agreed to place them
under MIT license.

See https://github.com/jbarlow83/OCRmyPDF/issues/600
2020-08-04 23:53:56 -07:00
James R. Barlow e821ca46d5 Approve pdfminer.six 20200726 2020-08-03 16:04:16 -07:00
James R. Barlow a29e4952fb Document use of mmap 2020-08-03 16:03:54 -07:00
James R. Barlow 4cc0dc6b4a Additional size increase reasons 2020-08-03 16:03:29 -07:00
James R. Barlow 7263702de9 Remove gs.py (spoofers entirely removed) and update copyright 2020-07-29 16:31:47 -07:00
77 changed files with 895 additions and 1640 deletions
+6 -7
View File
@@ -9,17 +9,16 @@ ocrmypdf ...arguments... input.pdf output.pdf
``` ```
**Example file** **Example file**
Please include an example *input* PDF (or image). The input file is more helpful. Please include an example *input* PDF (or image). You could also try to use of the files in ``tests/resources/`` to illustrate your issue.
Please check any or all that apply about the test file: Please check any or all that apply about the example file:
- [ ] This is the input file - [ ] This is the input file
- [ ] The file contains no personal or confidential information - [ ] The file contains no personal or confidential information
- [ ] I am the copyright holder for this file
- [ ] I permit this file to be included in the OCRmyPDF test suite under the CC-BY-SA 4.0 license
- [ ] I am not the copyright holder, but this file is available under a free software license
Files that are not free for inclusion in this project are quite welcome, but we like to collect free files for our test suite when possible. Please do *not* submit files with confidential information. At your option you may encrypt files for OCRmyPDF's author only. Please do *not* submit files with confidential information. At your option you may encrypt files for OCRmyPDF's author only.
Issues submitted without an example input file are less likely to be resolved. The output file is generally not helpful.
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. Include screenshots if applicable. A clear and concise description of what you expected to happen. Include screenshots if applicable.
@@ -27,7 +26,7 @@ A clear and concise description of what you expected to happen. Include screensh
**System:** **System:**
- OS: [e.g. Linux, macOS] - OS: [e.g. Linux, macOS]
- OCRmyPDF Version: [e.g. v7.4.0] - OCRmyPDF Version: [e.g. v10.3.0]
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.
+373 -674
View File
File diff suppressed because it is too large Load Diff
+8 -4
View File
@@ -127,11 +127,15 @@ OCRmyPDF would not be the software that it is today without companies and users
## License ## License
The OCRmyPDF software is licensed under the GNU GPLv3. Certain files are covered by other licenses, as noted in their source files. The OCRmyPDF software is licensed under the Mozilla Public License 2.0
(MPL-2.0). This license permits integration of OCRmyPDF with other code,
included commercial and closed source, but asks you to publish source-level
modifications you make to OCRmyPDF.
The license for each test file varies, and is noted in tests/resources/README.rst. The documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA 4.0). Some components of OCRmyPDF have other licenses, as noted in those files and the
``debian/copyright`` file. Most files in ``misc/`` use the MIT license, and the
OCRmyPDF versions prior to 6.0 were distributed under the MIT License. documentation and test files are generally licensed under Creative Commons
ShareAlike 4.0 (CC-BY-SA 4.0).
## Disclaimer ## Disclaimer
+39 -5
View File
@@ -5,15 +5,42 @@ Source: https://github.com/jbarlow83/OCRmyPDF
Files: * Files: *
Copyright: Copyright:
(C) 2013-2017 The OCRmyPDF Authors (C) 2013-2015 Julien Pfefferkorn
(C) 2013-2016, 2015-2017 2016, 2017, 2017-2018, 2018 James R. Barlow (C) 2015-2020 James R. Barlow
License: GPL-3+ (C) 2019 Martin Wind
License: MPL-2.0
Files: misc/*
Copyright:
(C) 2020 James R. Barlow
License: Expat
Files: misc/completion/ocrmypdf.bash
Copyright:
(C) 2019 Frank Pille
(C) 2020 Alex Willner
License: Expat
Files: misc/completion/ocrmypdf.fish
Copyright:
(C) 2020 James R. Barlow
License: Expat
Files: misc/batch.py
Copyright:
(C) 2016 findingorder: https://github.com/findingorder
License: Expat
Files: misc/synology.py
Copyright:
(C) github.com/Enantiomerie
License: Expat
Files: misc/watcher.py Files: misc/watcher.py
Copyright: Copyright:
(C) 2019 Ian Alexander: https://github.com/ianalexander (C) 2019 Ian Alexander: https://github.com/ianalexander
(C) 2020 James R. Barlow (C) 2020 James R. Barlow
License: GPL-3+ License: Expat
Files: misc/webservice.py Files: misc/webservice.py
Copyright: (C) 2019 James R. Barlow Copyright: (C) 2019 James R. Barlow
@@ -43,7 +70,7 @@ Copyright: (C) 2014 Armin Ronacher
(C) 2017 James R. Barlow (C) 2017 James R. Barlow
License: BSD-3-clause License: BSD-3-clause
Files: tests/spoof/* Files: tests/plugins/*
Copyright: (C) 2016, 2017, 2016-2018 James R. Barlow Copyright: (C) 2016, 2017, 2016-2018 James R. Barlow
License: Expat License: Expat
@@ -132,6 +159,13 @@ Files: debian/*
Copyright: (C) 2016 Sean Whitton <spwhitton@spwhitton.name> Copyright: (C) 2016 Sean Whitton <spwhitton@spwhitton.name>
License: GPL-3+ License: GPL-3+
License: MPL-2.0
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0.
.
On Debian systems the full text of the MPL-2.0 can be found in
/usr/share/common-licenses/MPL-2.0.
License: GPL-3+ License: GPL-3+
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
+4
View File
@@ -51,6 +51,10 @@ Forking a child process to call ``ocrmypdf.ocr()`` is suggested. That
way your application will survive and remain interactive even if way your application will survive and remain interactive even if
OCRmyPDF does not. OCRmyPDF does not.
Programs that call ``ocrmypdf.ocr()`` should also install a SIGBUS signal
handler (except on Windows), to raise an exception if access to a memory
mapped file fails. OCRmyPDF may use memory mapping.
.. warning:: .. warning::
On Windows, the script that calls ``ocrmypdf.ocr()`` must be protected On Windows, the script that calls ``ocrmypdf.ocr()`` must be protected
+11 -1
View File
@@ -32,7 +32,8 @@ If you are proposing a change that will require a new Python dependency, we
prefer dependencies that are already packaged by Debian or Red Hat. This makes prefer dependencies that are already packaged by Debian or Red Hat. This makes
life much easier for our downstream package maintainers. life much easier for our downstream package maintainers.
Python dependencies must also be GPLv3 compatible. Python dependencies must also be license-compatible. GPLv3 or AGPLv3 are likely
incompatible with the project's license, but LGPLv3 is compatible.
New non-Python dependencies New non-Python dependencies
=========================== ===========================
@@ -55,3 +56,12 @@ of that platform.
Packager maintainers, please ensure that the command line completion scripts in Packager maintainers, please ensure that the command line completion scripts in
``misc/`` are installed. ``misc/`` are installed.
Copyright and license
=====================
For contributions over 10 lines of code, please include your name to list of
copyright holders for that file. The core program is licensed under MPL-2.0,
test files and documentation under CC-BY-SA 4.0, and miscellaneous files under
MIT. Please contribute code only that you wrote and you have the permission to
contribute or license to us.
+1 -2
View File
@@ -163,8 +163,7 @@ complete. This may entail setting a long timeout; this interface is more
useful for internal HTTP API calls. useful for internal HTTP API calls.
Unlike the rest of OCRmyPDF, this web service is licensed under the Unlike the rest of OCRmyPDF, this web service is licensed under the
Affero GPLv3 (AGPLv3) since Ghostscript, a dependency of OCRmyPDF, is Affero GPLv3 (AGPLv3) since Ghostscript is also licensed in this way.
also licensed in this way.
In addition to the above, please read our In addition to the above, please read our
:ref:`general remarks on using OCRmyPDF as a service <ocr-service>`. :ref:`general remarks on using OCRmyPDF as a service <ocr-service>`.
+5
View File
@@ -186,6 +186,11 @@ Ghostscript also imposes some limitations:
- Ghostscript's PDF/A conversion removes any XMP metadata that is not - Ghostscript's PDF/A conversion removes any XMP metadata that is not
one of the standard XMP metadata namespaces for PDFs. In particular, one of the standard XMP metadata namespaces for PDFs. In particular,
PRISM Metdata is removed. PRISM Metdata is removed.
- Ghostscript's PDF/A conversion seems to remove or deactivate
hyperlinks and other active content.
You can use ``--output-type pdf`` to disable PDF/A conversion and produce
a standard, non-archival PDF.
Regarding OCRmyPDF itself: Regarding OCRmyPDF itself:
+1 -1
View File
@@ -64,7 +64,7 @@ malicious user could upload a chosen PDF. In particular, it is not
necessarily secure against PDF malware or PDFs that cause denial of necessarily secure against PDF malware or PDFs that cause denial of
service. OCRmyPDF relies on Ghostscript, and therefore, if deployed service. OCRmyPDF relies on Ghostscript, and therefore, if deployed
online one should be prepared to comply with Ghostscript's Affero GPL online one should be prepared to comply with Ghostscript's Affero GPL
license, OCRmyPDF's GPL license, and any other licenses. license, and any other licenses.
Setting aside these concerns, a side effect of OCRmyPDF is it may Setting aside these concerns, a side effect of OCRmyPDF is it may
incidentally sanitize PDFs that contain certain types of malware. It incidentally sanitize PDFs that contain certain types of malware. It
+27 -7
View File
@@ -12,14 +12,34 @@ may be unreliable. Use the API to depend on precise behavior.
The public API may be useful in scripts that launch OCRmyPDF processes or that The public API may be useful in scripts that launch OCRmyPDF processes or that
wish to use some of its features for working with PDFs. wish to use some of its features for working with PDFs.
Note that it is licensed under GPLv3, so scripts that v11.0.0
``import ocrmypdf`` and are released publicly should probably also be =======
licensed under GPLv3.
- Project license changed to Mozilla Public License 2.0. Some miscellaneous
code is now under MIT license and non-code content/media remains under
CC-BY-SA 4.0. License changed with approval of all people who were found
to have contributed to GPLv3 licensed sections of the project. (#600)
- Because the license changed, this is being treated as a major version number
change; however, there are no known breaking changes in functional behavior
or API compared to v10.x.
v10.3.3
=======
- Fixed a "KeyError: 'dpi'" error message when using ``--threshold`` on an image.
(#607)
v10.3.2
=======
- Fixed a case where we reported "no reason" for a file size increase, when we
could determine the reason.
- Enabled support for pdfminer.six 20200726.
v10.3.1 v10.3.1
======= =======
- Fixed a number of test suite failures with pdfminer.six older than veresion 20200420. - Fixed a number of test suite failures with pdfminer.six older than veresion 20200402.
- Enabled support for pdfminer.six 20200720. - Enabled support for pdfminer.six 20200720.
v10.3.0 v10.3.0
@@ -362,7 +382,7 @@ v9.0.0
- Added a high level API for applications that want to integrate OCRmyPDF. - Added a high level API for applications that want to integrate OCRmyPDF.
Special thanks to Martin Wind (@mawi1988) whose made significant contributions Special thanks to Martin Wind (@mawi1988) whose made significant contributions
to this effort. OCRmyPDF is GPLv3-licensed. to this effort.
- Added progress bars for long-running steps. ■■■■■■■□□ - Added progress bars for long-running steps. ■■■■■■■□□
- We now create linearized ("fast web view") PDFs by default. The new parameter - We now create linearized ("fast web view") PDFs by default. The new parameter
``--fast-web-view`` provides control over when this feature is applied. ``--fast-web-view`` provides control over when this feature is applied.
@@ -989,8 +1009,8 @@ v6.1.0
v6.0.0 v6.0.0
====== ======
- The software license has been changed to GPLv3. Test resource files - The software license has been changed to GPLv3 [it has since changed again].
and some individual sources may have other licenses. Test resource files and some individual sources may have other licenses.
- OCRmyPDF now depends on - OCRmyPDF now depends on
`PyMuPDF <https://pymupdf.readthedocs.io/en/latest/installation/>`__. `PyMuPDF <https://pymupdf.readthedocs.io/en/latest/installation/>`__.
Including PyMuPDF is the primary reason for the change to GPLv3. Including PyMuPDF is the primary reason for the change to GPLv3.
+19 -1
View File
@@ -1,5 +1,23 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Original version by DeliciousPickle@github; modified # Copyright 2016 findingorder: https://github.com/findingorder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This script must be edited to meet your needs. # This script must be edited to meet your needs.
+21
View File
@@ -1,5 +1,26 @@
# ocrmypdf completion -*- shell-script -*- # ocrmypdf completion -*- shell-script -*-
# Copyright 2019 Frank Pille
# Copyright 2020 Alex Willner
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -o errexit set -o errexit
_ocrmypdf() _ocrmypdf()
+20
View File
@@ -1,3 +1,23 @@
# Copyright 2020 James R. Barlow
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
complete -c ocrmypdf -x -n '__fish_is_first_arg' -l version complete -c ocrmypdf -x -n '__fish_is_first_arg' -l version
complete -c ocrmypdf -x -n '__fish_is_first_arg' -s h -s "?" -l help complete -c ocrmypdf -x -n '__fish_is_first_arg' -s h -s "?" -l help
+15 -10
View File
@@ -1,17 +1,22 @@
# © 2020 James R Barlow: https://github.com/jbarlow83 # © 2020 James R Barlow: https://github.com/jbarlow83
# #
# This program is free software: you can redistribute it and/or modify # Permission is hereby granted, free of charge, to any person obtaining a copy
# it under the terms of the GNU General Public License as published by # of this software and associated documentation files (the "Software"), to deal
# the Free Software Foundation, either version 3 of the License, or # in the Software without restriction, including without limitation the rights
# (at your option) any later version. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# #
# This program is distributed in the hope that it will be useful, # The above copyright notice and this permission notice shall be included in all
# but WITHOUT ANY WARRANTY; without even the implied warranty of # copies or substantial portions of the Software.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# along with this program. If not, see <http://www.gnu.org/licenses/>. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import logging import logging
+19 -1
View File
@@ -1,5 +1,23 @@
#!/bin/env python3 #!/bin/env python3
# Contributed by github.com/Enantiomerie # Copyright 2017 github.com/Enantiomerie
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This script must be edited to meet your needs. # This script must be edited to meet your needs.
+15 -10
View File
@@ -1,18 +1,23 @@
# Copyright (C) 2019 Ian Alexander: https://github.com/ianalexander # Copyright (C) 2019 Ian Alexander: https://github.com/ianalexander
# Copyright (C) 2020 James R Barlow: https://github.com/jbarlow83 # Copyright (C) 2020 James R Barlow: https://github.com/jbarlow83
# #
# This program is free software: you can redistribute it and/or modify # Permission is hereby granted, free of charge, to any person obtaining a copy
# it under the terms of the GNU General Public License as published by # of this software and associated documentation files (the "Software"), to deal
# the Free Software Foundation, either version 3 of the License, or # in the Software without restriction, including without limitation the rights
# (at your option) any later version. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# #
# This program is distributed in the hope that it will be useful, # The above copyright notice and this permission notice shall be included in all
# but WITHOUT ANY WARRANTY; without even the implied warranty of # copies or substantial portions of the Software.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# along with this program. If not, see <http://www.gnu.org/licenses/>. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import json import json
import logging import logging
+6 -16
View File
@@ -2,20 +2,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2015 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function, unicode_literals from __future__ import print_function, unicode_literals
@@ -60,7 +50,7 @@ setup(
"Intended Audience :: End Users/Desktop", "Intended Audience :: End Users/Desktop",
"Intended Audience :: Science/Research", "Intended Audience :: Science/Research",
"Intended Audience :: System Administrators", "Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Operating System :: MacOS :: MacOS X", "Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows :: Windows 10", "Operating System :: Microsoft :: Windows :: Windows 10",
"Operating System :: POSIX", "Operating System :: POSIX",
@@ -83,7 +73,7 @@ setup(
'cffi >= 1.9.1', # must be a setup and install requirement 'cffi >= 1.9.1', # must be a setup and install requirement
'coloredlogs >= 14.0', # strictly optional 'coloredlogs >= 14.0', # strictly optional
'img2pdf >= 0.3.0, < 0.4', # pure Python, so track HEAD closely 'img2pdf >= 0.3.0, < 0.4', # pure Python, so track HEAD closely
'pdfminer.six >= 20191110, <= 20200720', 'pdfminer.six >= 20191110, <= 20200726',
'pikepdf >= 1.14.0, < 2', 'pikepdf >= 1.14.0, < 2',
'Pillow >= 7.0.0', 'Pillow >= 7.0.0',
'pluggy >= 0.13.0', 'pluggy >= 0.13.0',
+3 -14
View File
@@ -1,19 +1,8 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from pluggy import HookimplMarker as _HookimplMarker from pluggy import HookimplMarker as _HookimplMarker
+4 -14
View File
@@ -1,20 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# © 2015-19 James R. Barlow: github.com/jbarlow83 # © 2015-19 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import os import os
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import logging.handlers import logging.handlers
+4 -14
View File
@@ -1,18 +1,8 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Manage third party executables""" """Manage third party executables"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Interface to Ghostscript executable""" """Interface to Ghostscript executable"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Interface to jbig2 executable""" """Interface to jbig2 executable"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Interface to pngquant executable""" """Interface to pngquant executable"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Interface to Tesseract executable""" """Interface to Tesseract executable"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2015 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
# unpaper documentation: # unpaper documentation:
# https://github.com/Flameeyes/unpaper/blob/master/doc/basic-concepts.md # https://github.com/Flameeyes/unpaper/blob/master/doc/basic-concepts.md
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
from contextlib import suppress from contextlib import suppress
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import os import os
import shutil import shutil
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import sys import sys
+7 -15
View File
@@ -1,19 +1,9 @@
# © 2016 James R. Barlow: github.com/jbarlow83 # © 2016 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import os import os
@@ -530,7 +520,9 @@ def create_ocr_image(image: Path, page_context: PageContext):
if options.threshold: if options.threshold:
pix = leptonica.Pix.frompil(im) pix = leptonica.Pix.frompil(im)
pix = pix.masked_threshold_on_background_norm() pix = pix.masked_threshold_on_background_norm()
im = pix.topil() im_pix = pix.topil()
im_pix.info['dpi'] = im.info['dpi']
im = im_pix
del draw del draw
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import argparse import argparse
import importlib import importlib
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2016 James R. Barlow: github.com/jbarlow83 # © 2016 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import logging.handlers import logging.handlers
+7 -14
View File
@@ -1,20 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# © 2015-17 James R. Barlow: github.com/jbarlow83 # © 2015-17 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import locale import locale
@@ -416,6 +405,10 @@ def report_output_file_size(options, input_file, output_file):
f"The optional dependency '{name}' was not found, so some image " f"The optional dependency '{name}' was not found, so some image "
f"optimizations could not be attempted." f"optimizations could not be attempted."
) )
if options.output_type.startswith('pdfa'):
reasons.append("PDF/A conversion was enabled. (Try `--output-type pdf`.)")
if options.plugins:
reasons.append("Plugins were used.")
if reasons: if reasons:
explanation = "Possible reasons for this include:\n" + '\n'.join(reasons) + "\n" explanation = "Possible reasons for this include:\n" + '\n'.join(reasons) + "\n"
+3 -14
View File
@@ -1,19 +1,8 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import pkg_resources import pkg_resources
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import os import os
+3 -14
View File
@@ -1,16 +1,5 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import os import os
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2015-19 James R. Barlow: github.com/jbarlow83 # © 2015-19 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import argparse import argparse
+3 -14
View File
@@ -1,19 +1,8 @@
# © 2016 James R. Barlow: github.com/jbarlow83 # © 2016 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from enum import IntEnum from enum import IntEnum
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2016 James R. Barlow: github.com/jbarlow83 # © 2016 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import multiprocessing import multiprocessing
+4 -14
View File
@@ -3,20 +3,10 @@
# #
# © 2013-16: jbarlow83 from Github (https://github.com/jbarlow83) # © 2013-16: jbarlow83 from Github (https://github.com/jbarlow83)
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
# #
# Python FFI wrapper for Leptonica library # Python FFI wrapper for Leptonica library
+4 -14
View File
@@ -1,18 +1,8 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Bindings to external libraries""" """Bindings to external libraries"""
+4 -14
View File
@@ -1,20 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from pathlib import Path from pathlib import Path
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import sys import sys
+54 -43
View File
@@ -1,19 +1,9 @@
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
""" """
Utilities for PDF/A production and confirmation with Ghostspcript. Utilities for PDF/A production and confirmation with Ghostspcript.
@@ -21,8 +11,7 @@ Utilities for PDF/A production and confirmation with Ghostspcript.
import base64 import base64
from pathlib import Path from pathlib import Path
from string import Template from typing import Dict, Iterator, Union
from typing import Dict, Union
import pikepdf import pikepdf
import pkg_resources import pkg_resources
@@ -32,29 +21,56 @@ ICC_PROFILE_RELPATH = 'data/sRGB.icc'
SRGB_ICC_PROFILE = pkg_resources.resource_filename('ocrmypdf', ICC_PROFILE_RELPATH) 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 def _postscript_objdef(
# files, from the Ghostscript documentation. Lines beginning with % are alias: str,
# comments. Python substitution variables have a '$' prefix. dictionary: Dict[str, str],
pdfa_def_template = u"""%! *,
% Define an ICC profile : stream_name: str = None,
/ICCProfile $icc_profile stream_data: bytes = None,
def ) -> Iterator[str]:
assert (stream_name is None) == (stream_data is None)
[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark objtype = '/stream' if stream_name else '/dict'
[{icc_PDFA} << /N 3 >> /PUT pdfmark
[{icc_PDFA} ICCProfile /PUT pdfmark
% Define the output intent dictionary : if stream_name:
a85_data = base64.a85encode(stream_data, adobe=True).decode('ascii')
yield f'{stream_name} ' + a85_data
yield 'def'
[/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark if alias != '{Catalog}': # Catalog needs no definition
[{OutputIntent_PDFA} << yield f'[/_objdef {alias} /type {objtype} /OBJ pdfmark'
/Type /OutputIntent % Must be so (the standard requires).
/S /GTS_PDFA1 % Must be so (the standard requires). yield f'[{alias} <<'
/DestOutputProfile {icc_PDFA} % Must be so (see above). for key, val in dictionary.items():
/OutputConditionIdentifier ($icc_identifier) yield f' {key} {val}'
>> /PUT pdfmark yield '>> /PUT pdfmark'
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark
""" if stream_name:
yield f'[{alias} {stream_name[1:]} /PUT pdfmark'
def _make_postscript(icc_name: str, icc_data: bytes, colors: int) -> Iterator[str]:
yield '%!'
yield from _postscript_objdef(
'{icc_PDFA}', # Not an f-string
{'/N': str(colors)},
stream_name='/ICCProfile',
stream_data=icc_data,
)
yield ''
yield from _postscript_objdef(
'{OutputIntent_PDFA}',
{
'/Type': '/OutputIntent',
'/S': '/GTS_PDFA1',
'/DestOutputProfile': '{icc_PDFA}',
'/OutputConditionIdentifier': f'({icc_name})', # Only f-string
},
)
yield ''
yield from _postscript_objdef(
'{Catalog}', {'/OutputIntents': '[ {OutputIntent_PDFA} ]'}
)
def generate_pdfa_ps(target_filename: Path, icc: str = 'sRGB'): def generate_pdfa_ps(target_filename: Path, icc: str = 'sRGB'):
@@ -85,13 +101,8 @@ def generate_pdfa_ps(target_filename: Path, icc: str = 'sRGB'):
else: else:
raise NotImplementedError("Only supporting sRGB") raise NotImplementedError("Only supporting sRGB")
# Read the ICC profile, encode as ASCII85 and convert to a string which we
# will insert in the .ps file
bytes_icc_profile = Path(icc_profile).read_bytes() bytes_icc_profile = Path(icc_profile).read_bytes()
icc_profile = base64.a85encode(bytes_icc_profile, adobe=True).decode('ascii') ps = '\n'.join(_make_postscript(icc, bytes_icc_profile, 3))
t = Template(pdfa_def_template)
ps = t.substitute(icc_profile=icc_profile, icc_identifier=icc)
# We should have encoded everything to pure ASCII by this point, and # We should have encoded everything to pure ASCII by this point, and
# to be safe, only allow ASCII in PostScript # to be safe, only allow ASCII in PostScript
+4 -14
View File
@@ -1,19 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2015 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from ocrmypdf.pdfinfo.info import Colorspace, Encoding, PdfInfo from ocrmypdf.pdfinfo.info import Colorspace, Encoding, PdfInfo
+4 -14
View File
@@ -1,20 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2015 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import re import re
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import re import re
from math import copysign from math import copysign
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from abc import ABC, abstractmethod, abstractstaticmethod from abc import ABC, abstractmethod, abstractstaticmethod
from argparse import ArgumentParser, Namespace from argparse import ArgumentParser, Namespace
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Utilities to measure OCR quality""" """Utilities to measure OCR quality"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
"""Wrappers to manage subprocess calls""" """Wrappers to manage subprocess calls"""
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import os import os
import platform import platform
-40
View File
@@ -1,40 +0,0 @@
# © 2019 James R. Barlow: github.com/jbarlow83
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Find Ghostscript executable"""
import os
import shutil
def real_ghostscript(argv):
if os.name != 'nt':
gs = shutil.which('gs')
gs_args = [gs] + argv[1:]
os.execv(gs_args[0], gs_args)
else:
gs = shutil.which('gswin64c')
if not gs:
gs = shutil.which('gswin32c')
os.execv(gs, argv[1:])
return # Not reachable
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
from io import BytesIO, StringIO from io import BytesIO, StringIO
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import PIPE, run from subprocess import PIPE, run
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
from decimal import Decimal from decimal import Decimal
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from unittest.mock import patch from unittest.mock import patch
+5 -15
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import multiprocessing import multiprocessing
@@ -22,7 +12,7 @@ from unittest.mock import MagicMock
import pytest import pytest
import ocrmypdf.helpers as helpers from ocrmypdf import helpers as helpers
from ocrmypdf.subprocess import shim_paths_with_program_files from ocrmypdf.subprocess import shim_paths_with_program_files
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2015 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import re import re
from io import StringIO from io import StringIO
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from unittest.mock import patch from unittest.mock import patch
+3 -14
View File
@@ -1,19 +1,8 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from os import fspath from os import fspath
+18 -14
View File
@@ -1,19 +1,9 @@
# © 2015-19 James R. Barlow: github.com/jbarlow83 # © 2015-19 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import os import os
import shutil import shutil
@@ -877,3 +867,17 @@ def test_image_dpi_not_image(caplog, resources, outpdf):
'tests/plugins/tesseract_noop.py', 'tests/plugins/tesseract_noop.py',
) )
assert '--image-dpi is being ignored' in caplog.text assert '--image-dpi is being ignored' in caplog.text
def test_image_dpi_threshold(resources, outpdf):
check_ocrmypdf(
resources / 'typewriter.png',
outpdf,
'--threshold',
'--image-dpi=170',
'--output-type=pdf',
'--optimize=0',
'--plugin',
'tests/plugins/tesseract_noop.py',
)
assert outpdf.exists()
+3 -14
View File
@@ -1,19 +1,8 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import datetime import datetime
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from os import fspath from os import fspath
from pathlib import Path from pathlib import Path
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2015 James R. Barlow: github.com/jbarlow83 # © 2015 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import pickle import pickle
from math import isclose from math import isclose
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from math import isclose from math import isclose
+5 -15
View File
@@ -1,23 +1,13 @@
# © 2020 James R. Barlow: github.com/jbarlow83 # © 2020 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import ocrmypdf.quality as qual from ocrmypdf import quality as qual
def test_quality_measurement(): def test_quality_measurement():
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2018 James R. Barlow: github.com/jbarlow83 # © 2018 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from io import BytesIO from io import BytesIO
from os import fspath from os import fspath
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import os import os
import sys import sys
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import os import os
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2015-17 James R. Barlow: github.com/jbarlow83 # © 2015-17 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from os import fspath from os import fspath
from unittest.mock import patch from unittest.mock import patch
+4 -14
View File
@@ -1,19 +1,9 @@
# © 2017 James R. Barlow: github.com/jbarlow83 # © 2017 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from math import isclose from math import isclose
+7 -17
View File
@@ -1,19 +1,9 @@
# © 2019 James R. Barlow: github.com/jbarlow83 # © 2019 James R. Barlow: github.com/jbarlow83
# #
# This file is part of OCRmyPDF. # This Source Code Form is subject to the terms of the Mozilla Public
# # License, v. 2.0. If a copy of the MPL was not distributed with this
# OCRmyPDF is free software: you can redistribute it and/or modify # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
from unittest.mock import patch from unittest.mock import patch
@@ -21,7 +11,7 @@ from unittest.mock import patch
import pikepdf import pikepdf
import pytest import pytest
import ocrmypdf._validation as vd from ocrmypdf import _validation as vd
from ocrmypdf._plugin_manager import get_plugin_manager from ocrmypdf._plugin_manager import get_plugin_manager
from ocrmypdf.api import create_options from ocrmypdf.api import create_options
from ocrmypdf.cli import get_parser from ocrmypdf.cli import get_parser
@@ -141,7 +131,7 @@ def test_report_file_size(tmp_path, caplog):
pdf = pikepdf.new() pdf = pikepdf.new()
pdf.save(in_) pdf.save(in_)
pdf.save(out) pdf.save(out)
opts = make_opts() opts = make_opts(output_type='pdf')
vd.report_output_file_size(opts, in_, out) vd.report_output_file_size(opts, in_, out)
assert caplog.text == '' assert caplog.text == ''
caplog.clear() caplog.clear()
@@ -166,7 +156,7 @@ def test_report_file_size(tmp_path, caplog):
assert 'optional dependency' in caplog.text assert 'optional dependency' in caplog.text
caplog.clear() caplog.clear()
opts = make_opts(in_, out, optimize=0) opts = make_opts(in_, out, optimize=0, output_type='pdf')
vd.report_output_file_size(opts, in_, out) vd.report_output_file_size(opts, in_, out)
assert 'disabled' in caplog.text assert 'disabled' in caplog.text
caplog.clear() caplog.clear()