diff --git a/.gitignore b/.gitignore index a6aaa1e..936d817 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc .* *~ +scanpdf.egg-info diff --git a/scanpdf.egg-info/PKG-INFO b/scanpdf.egg-info/PKG-INFO deleted file mode 100644 index 1ca6e47..0000000 --- a/scanpdf.egg-info/PKG-INFO +++ /dev/null @@ -1,105 +0,0 @@ -Metadata-Version: 1.0 -Name: scanpdf -Version: 0.3.0 -Summary: Utility to use SANE/scanadf to scan to PDF -Home-page: UNKNOWN -Author: Virantha N. Ekanayake -Author-email: virantha@gmail.com -License: ASL 2.0 -Description: Scan PDF - Easy scans in Linux with a document scanner like the Fujitsu ScanSnap - ################################################################################ - - .. image:: http://badge.fury.io/py/scanpdf.png - :target: http://badge.fury.io/py/scanpdf - - .. image:: http://pypip.in/d/scanpdf/badge.png - :target: https://crate.io/packages/scanpdf?version=latest - - - If you're looking for a simple way to use a multi-page scanner and get your - document into a PDF in Linux without any proprietary or commercial software, - then ScanPDF might be the solution. I wrote it to quickly take the Linux SANE - scanner system output image files, and process them into usable PDFs. By - usable, I mean PDFs that maintain their original scanned resolution, omit blank - pages (if you're scanning in duplex mode, for example), preserve color unless - the original is greyscale/black and white, in which case they are intelligently - down-converted to B/W PDFs to save space. - - * Free and open-source software: ASL2 license - * Documentation: http://virantha.github.io/scanpdf/html - * Source: https://github.com/virantha/scanpdf - - Features - -------- - * Uses SANE/scanadf to automatically scan to multi-page compressed PDFs - * `Integrates with ScanBd `_ to respond to hardware button presses - * Automatically removes blank pages. - * Scans in color, and automatically down-converts into 1-bit B/W image for text/greyscale images - - Usage: - ------ - The simplest way to use this is: - - :: - - scanpdf scan pdf - - This will first perform the scan, and then the conversion to PDF. If you want - to split up the scan and the PDF conversion into two separate invocations (for - reasons clarified below), then you can do: - - :: - - scanpdf --tmpdir=tmp scan - scanpdf --tmpdir=tmp pdf - - One reason for the separation might be if you want to keep scanning documents - (very quick) while the post-processing (slower) for the PDF conversion is - taking place in the background. For instance, if you're using the hardware - button on the scanner to initiate scans (as detailed in this_ document), then - you want to return immediately after the scan instead of waiting for the full - conversion to PDF has taken place. - - .. _this: http://virantha.com/2014/03/17/one-touch-scanning-with-fujitsu-scansnap-in-linux/ - - You can optionally use the following switches to control if you're putting pages face up or face down in the auto - document feeder, if you want to skip the blank page processing, adjust the blank page detection threshold, or add - additional post-processing using unpaper_: - - .. _unpaper: http://unpaper.berlios.de - - :: - - --dpi= DPI to scan in [default: 300] - --face-up= Face-up scanning [default: True] - --keep-blanks Don't check for and remove blank pages - --blank-threshold= Percentage of white to be marked as blank [default: 0.97] - --post-process Run unpaper to deskew/clean up - - - Right now, I'm assuming this is getting called via ScanBD, so I don't have the option to manually specify the - scanner. If you really want to use this standalone, for now, please just set the ``SCANBD_DEVICE`` environment - variable to your scanner device name before running this script. - - - Installation - ------------ - :: - - $ pip install scanpdf - - Requires ImageMagick and SANE to be installed, for the command line tools: - - * ``convert`` - * ``identify`` - * ``ps2pdf`` - * ``scanadf`` - - Also requires epstopdf. - - Disclaimer - ---------- - The software is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - -Platform: UNKNOWN diff --git a/scanpdf.egg-info/SOURCES.txt b/scanpdf.egg-info/SOURCES.txt deleted file mode 100644 index 71b4f80..0000000 --- a/scanpdf.egg-info/SOURCES.txt +++ /dev/null @@ -1,21 +0,0 @@ -AUTHORS.rst -CHANGES.rst -CONTRIBUTING.rst -HISTORY.rst -LICENSE.txt -MANIFEST.in -README.rst -TODO.rst -requirements.txt -setup.py -scanpdf/__init__.py -scanpdf/scanpdf.py -scanpdf/version.py -scanpdf.egg-info/PKG-INFO -scanpdf.egg-info/SOURCES.txt -scanpdf.egg-info/dependency_links.txt -scanpdf.egg-info/entry_points.txt -scanpdf.egg-info/requires.txt -scanpdf.egg-info/top_level.txt -scanpdf.egg-info/zip-safe -test/test_scanpdf.py \ No newline at end of file diff --git a/scanpdf.egg-info/dependency_links.txt b/scanpdf.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/scanpdf.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scanpdf.egg-info/entry_points.txt b/scanpdf.egg-info/entry_points.txt deleted file mode 100644 index c30442e..0000000 --- a/scanpdf.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -scanpdf = scanpdf.scanpdf:main - diff --git a/scanpdf.egg-info/requires.txt b/scanpdf.egg-info/requires.txt deleted file mode 100644 index 7920c79..0000000 --- a/scanpdf.egg-info/requires.txt +++ /dev/null @@ -1 +0,0 @@ -docopt>=0.6.1 \ No newline at end of file diff --git a/scanpdf.egg-info/top_level.txt b/scanpdf.egg-info/top_level.txt deleted file mode 100644 index e9e5df7..0000000 --- a/scanpdf.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -scanpdf diff --git a/scanpdf.egg-info/zip-safe b/scanpdf.egg-info/zip-safe deleted file mode 100644 index 8b13789..0000000 --- a/scanpdf.egg-info/zip-safe +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scanpdf/scanpdf.py b/scanpdf/scanpdf.py index ceb2079..7ea39e7 100644 --- a/scanpdf/scanpdf.py +++ b/scanpdf/scanpdf.py @@ -30,7 +30,8 @@ --keep-blanks Don't check for and remove blank pages --blank-threshold= Percentage of white to be marked as blank [default: 0.97] --post-process Run unpaper to deskew/clean up - + --device= Set the device [default: the SCANBD_DEVICE environment variable] + --sanedir= Set the SANE configuration directory [default: /etc/scanbd] """ import sys, os @@ -38,7 +39,7 @@ import shutil import re -from version import __version__ +from .version import __version__ import docopt import subprocess @@ -74,9 +75,9 @@ def cmd(self, cmd_list): def run_scan(self): - device = os.environ['SCANBD_DEVICE'] + device = os.environ['SCANBD_DEVICE'] if self.scandevice is None else self.scandevice self.cmd('logger -t "scanbd: " "Begin of scan "') - c = ['SANE_CONFIG_DIR=/etc/scanbd', + c = ['SANE_CONFIG_DIR="%s"' % self.sanedir, 'scanadf', '-d "%s"' % device, '--source "ADF Duplex"', @@ -443,6 +444,16 @@ def get_options(self, argv): if self.args['pdf']: self.pdf_filename = os.path.abspath(self.args['']) + if argv["--sanedir"]: + self.sanedir = argv["--sanedir"] + else: + self.sanedir = "/etc/scanbd" + + if argv["--device"] and argv["--device"] != "the SCANBD_DEVICE environment variable": + self.scandevice = argv["--device"] + else: + self.scandevice = None + self.dpi = int(self.args['--dpi']) output_dir = time.strftime('%Y%m%d_%H%M%S', time.localtime())