Available Functions
- scanline_wrapper.list_scanners(browsesecs=1, verbose=False)
Get a list of available scanners.
Example:
>>> import scanline_wrapper >>> scanline_wrapper.list_scanners() ... ['HP Color LaserJet MFP M281fdw (035F4A)', 'My other scanner']
- Parameters:
browsesecs (int) – Specify how long to wait when searching for scanners (in seconds, default:
1).verbose (bool) – Increase verbosity of scanline logs (default:
False).
- Raises:
ScanlineExecutableNotFound – if the scanline app is not installed.
subprocess.CalledProcessError – if something goes wrong while running the scanline command.
- Return type:
list(str)
- Returns:
the available scanners.
- scanline_wrapper.scan_flatbed(output_path, scanner=None, is_scanner_exact_name=False, page_size=PageSize.A4, file_format=FileFormat.AUTO, color=Color.COLOR, resolution=150, browsesecs=1, verbose=False)
Scans a document using the flatbed unit of the scanner.
Simple example:
>>> import scanline_wrapper >>> scanline_wrapper.scan_flatbed("./out.tiff")
More complete example:
>>> import scanline_wrapper >>> scanline_wrapper.scan_flatbed( >>> "./out.jpg", >>> scanner="HP Color LaserJet MFP M281fdw (035F4A)", >>> page_size=scanline_wrapper.PageSize.LETTER, # A4, LEGAL or LETTER >>> file_format=scanline_wrapper.FileFormat.JPEG, # AUTO, PDF, TIFF or JPEG >>> color=scanline_wrapper.Color.COLOR, # COLOR or MONOCHROME >>> resolution=150, # DPI >>> )
- Parameters:
output_path (str,pathlib.Path) – The output file path.
scanner (str) – The name of the scanner to use. If not provided, the first available scanner will be used (default:
None).is_scanner_exact_name (bool) – If set to
True, scanline will try to fuzzy-match the scanner name (default:False).page_size (PageSize) – The size of the page to scan (default.
PageSize.A4).file_format (FileFormat) – The output file format. If set to
FileFormat.AUTOthe format will be infered from the file extension. AValueErrorwill be raised if the file extension does not match a supported format. (default:FileFormat.AUTO).color (Color) – Select color or monochrome scan (default:
Color.COLOR).resolution (int) – Specify minimum resolution at which to scan (in dpi, default:
150).browsesecs (int) – Specify how long to wait when searching for scanners (in seconds, default:
1).verbose (bool) – Increase verbosity of scanline logs (default:
False).
- Raises:
ScanlineScannerNotFound – if the scanner requested in
scannercannot be found or if no scanner are found.ScanlineInvalidPageSize – if the given page size is not one from the
PageSizeenum.ScanlineInvalidFileFormat – if the given file_format is not one from the
FileFormator if the file extension is not recognized when file format is set toFileFormat.AUTO.ScanlineInvalidColor – if the given page color is not one from the
Colorenum.ScanlineExecutableNotFound – if the scanline app is not installed.
ScanlineUnknownError – if scanline has not generated the expected output file without returning a specific error.
subprocess.CalledProcessError – if something goes wrong while running the scanline command.
- Return type:
None